Last update at :2024-02-11,Edit by888u
If we use the default WordPress program and theme and do not perform escape character processing, when the website Title contains the delimiter '-' horizontal line, it will often be automatically escaped into the HTML character –. This article will introduce two solutions to prohibit automatic escaping of title separators in WordPress websites. Let’s take a look at them together.
Open the functions.php file in the WordPress theme directory and add any of the following code snippets to the bottom of the functions.php file.
Solution 1: Disable all WP escaping
Wordpress comes with a dedicated hook wptexturize, which is used in many places. For details, you can look at wp's wp-includes/formatting.php. We can cancel this escape through the following code:
add_filter( ‘run_wptexturize’, ‘__return_false’ );Solution 2: Disable some WP escaping (recommended)
In order to solve the problem described in the title of this article, you can just disable wptexturize's escaping of the title:
remove_filter('the_title', 'wptexturize'); remove_filter('wp_title', 'wptexturize'); remove_filter('single_post_title', 'wptexturize');Recommended site search: European server, proxy IP, mainland China domain name, overseas virtual host space, host discount code, la domain name, free asp space, how to register company domain name, US host purchase, Hong Kong vps cloud server,
p>
发表评论