How to resolve WordPress double dash problem

Bloggers using WordPress might be facing issues with double dash being converted into the single dash.
This happens because of the wptexturize filter applied to the content by the WordPress.

There are two methods to disable the wptexturize filter.


1) Creating a plugin

Create a php file under wp-content/plugins/disable-wptexturize.php with following contents

Plugin Name: Remove the wptexturize filter
remove_filter( 'the_title' , 'wptexturize' );
remove_filter( 'the_content' , 'wptexturize' );
remove_filter( 'the_excerpt' , 'wptexturize' );
remove_filter( 'comment_text' , 'wptexturize' );
remove_filter( 'list_cats' , 'wptexturize' );

This is to remove the filter from post title, content, texcerpts, comment text & category lists.
Activate the plugin "Remove the wptexturize filter" from the admin panel and flush the cache if any cache plugin is in use.


2) Editing the WordPress file

Open the file wp-includes/formatting.php and search for the line below

$static_characters = array_merge( array( '---', ' -- ', '--', ' - ', 'xn&#8211;', '...', '``', '\'\'', ' (tm)' ), $cockney );

Replace the above line with

$static_characters = array_merge( array( /*'---', ' -- ', '--', ' - ', 'xn&#8211;', */'...', '``', '\'\'', ' (tm)' ), $cockney );

Save the file, flush WordPress cache and check.


Reference: WordPress support

Advise: Prefer solution 1 as updating WordPress will also overwrite changes made in the formatting.php file.


Share on Facebook2
Share on Google+9Tweet about this on TwitterShare on StumbleUpon0Share on LinkedIn0Share on Tumblr0Digg thisPin on Pinterest0Share on Reddit0Email this to someonePrint this page

About Abhijit Sandhan

Abhijit Sandhan
Loves Linux, Blogging, Traveling, Hiking and sharing knowledge!

Leave a Reply

Your email address will not be published. Required fields are marked *