Solve the string escape problem in WordPress

When you enter two "--" in WordPress, it will be recognized as a hyphen. If there is code in the article at this time, others will not be able to use it when copying and pasting. Here are three effective ways to solve this problem!

When you enter two "--" in WordPress, it will be recognized as a hyphen. If there is code in the article at this time, others will not be able to use it when copying and pasting. Here are three effective ways to solve this problem!

WordPress will automatically escape some characters by default, which is also called "converting full-width and half-width punctuation" or "code escaping" on the Internet. WordPress uses the wptexturize function to convert plain text characters into formatted HTML entities. This will cause all half-width characters in the code to be converted to full-width characters, and when others copy this code, they cannot use it and errors will occur. After collection and testing, this article lists three quick and effective solutions.

1. Solve the problem through plug-ins. You can install the Quotmarks Replacer plug-in and enable it directly. It is effective and fast.

2. Open the functions.php function file in the current theme and add the following code at the end of the file:

remove_filter('the_content', 'wptexturize');

3. Open the functions.php function file in the current theme and add the following code at the end of the file:

//Cancel content escape
remove_filter('the_content', 'wptexturize');
//Cancel digest escape
remove_filter('the_excerpt', 'wptexturize');
//Cancel comment escape
remove_filter('comment_text', 'wptexturize');

Of course there are other methods. I think the above three methods are the fastest and most effective!

score

Leave a Reply

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