Hosting – Domain – VPN – Business Review
Hosting

Simple code to solve WordPress article title “-” separator is escaped

When we look at the source code of the website built with WordPress, we see that the original “-” in the title is escaped into “&#8211”. In fact, this does not affect the user’s reading experience and the search engine, and the search engine will also reverse escape after indexing. It just feels uncomfortable to look at, so we can set to prohibit escaping.
1. Disable all WP escapes

WordPress comes with a dedicated hook wptexturize, which is used in many places. For details, you can take a look at wp-includes/formatting.php of wp. We can remove this escaping with the following code:

add_filter( ‘run_wptexturize’, ‘__return_false’ );

2. Disable some WP escapes

To solve the problem described by the title of this article, you can simply disable wptexturize from escaping the title:

remove_filter(‘the_title’, ‘wptexturize’);
remove_filter(‘wp_title’, ‘wptexturize’);
remove_filter(‘single_post_title’, ‘wptexturize’);

Related posts

Amazon cloud lightweight server install Windows system remote desktop management

admin
2 years ago

Linode’s acquisition of Akamai completed

admin
2 years ago

Is there a permanent free cloud host

admin
2 years ago
Exit mobile version