Techno World Inc - The Best Technical Encyclopedia Online!

THE TECHNO CLUB [ TECHNOWORLDINC.COM ] => PHP => Topic started by: Khushi on January 03, 2007, 12:40:59 AM



Title: Make Wordpress Stop Replacing Double Dash with Em-dash
Post by: Khushi on January 03, 2007, 12:40:59 AM
Wordpress by default replaces the double dash (--) with an em-dash character. If you are showing code or programming examples this will cause your visitors unnecessary confusion. This recipe shows the simple way to turn that behavior off.

This problem is occurring because Wordpress automatically runs a bunch of filters on your content before displaying it out to the browser. These filters include the smiley face replacement and others to try and clean up the content and make it more presentable to users. We will leave the rest of the filters alone.

Start by using either your ftp, ssh, or other client to open up the SITE_ROOT/wp-includes/functions-formatting.php file in a text editor and find these two lines:

Code:
$curl = str_replace(? -- ?, ? ? ?, $curl); 
$curl = str_replace(?--?, ???, $curl);

You can comment out these lines by putting the php // comment characters before them both, or you could simply delete the lines. When you are done, it should look like this:

Code:
//$curl = str_replace(? -- ?, ? ? ?, $curl); 
//$curl = str_replace(?--?, ???, $curl);

Now you will be able to see the double dash character in your blog posts, and no more comments from upset visitors saying that your examples aren't working. =)