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

WP Engine Review: A Top WordPress Hosting Provider

admin
1 year ago

Which MySQL management tool is better?

admin
8 months ago

Amazon cloud lightweight server install Windows system remote desktop management

admin
1 year ago
Exit mobile version