How to resolve WordPress double dash problem

Share with all..

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 with all..

About Abhijit Sandhan

Loves Open Source, Blogging, Traveling, Hiking and sharing Knowledge!

Leave a Reply

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