Focus on cloud service provider activities
Notes on website operation and maintenance

Solve the problem of outputting single and double quotation marks into Chinese characters in WordPress code

Lao Zuo didn't notice such a problem in the blog before. If the script shared in the blog post contains Single and double lead On the th. Everyone knows that only English characters can be used. When I input and write an article, I swear to God that it must be in English status, because I can use it in tests. But when we use the foreground copy and paste, it becomes Chinese character format. I didn't notice until today's "rising sea and bright moon" netizen asked me this question.

If you know that this problem can be solved, you can replace it manually. If you paste it directly, you will not notice this problem, so this problem needs to be solved. The following is "solve WordPress code Single and double lead Three methods to output Chinese characters.

One method is to modify the functions.php template file with one sentence of code

remove_filter('the_content', 'wptexturize');

This method is not bad. It simply does not need to install the plug-ins mentioned below, and it will not affect the upgrade of WP programs. This sentence is used to prohibit the wptexturize function. It can only be valid in the content, and the title, comment, etc. are not valid.

The second method is the Quota Replacer plug-in

The Quotmarks Replacer plug-in is downloaded and installed from the WP official. It is also used to prohibit the wptexturize function and the conversion of half width single and double quotation marks to full width format. Try to install as few plug-ins as possible, but this plug-in is relatively small, so it's OK to install it.

Method 3: Modify the program source file

Modify the wp includes/formatting. php file to find the following code

// static strings
$curl = str_replace($static_characters, $static_replacements, $curl);
// regular expressions
$curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);

Modify to

// static strings
// $curl = str_replace($static_characters, $static_replacements, $curl);
// regular expressions
// $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);

Log off the code function. This method needs to pay attention to whether it is updated when upgrading the program, and then it needs to be modified again.

From the effect of the three methods, Lao Zuo suggested using the first method.

Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( zero )
Do not reprint without permission: Lao Zuo's Notes » Solve the problem of outputting single and double quotation marks into Chinese characters in WordPress code


Scan the code to follow the official account

Get more news about webmaster circle!
Entrepreneurship, operation and new knowledge