How To

How to resolve WordPress double dash problem

The WordPress bloggers 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 as discussed below:

Solution 1: Creating a WordPress plugin

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

<?php
/*
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, excerpts, 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.

Solution 2: By 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

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

Related Articles

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button