Provide zblog template_zblog them_wordpress template download and customization

Solution to the problem that Wordpress calls the article content label and the article content does not break lines

Tianxing Studio 2022-02-22 20:30 Wordpress Tutorial one thousand and thirty-two 0 Comments


write Wordpress template The tag "$post ->post_content" is always used to call the article content, but one user feedback that the article content keeps running.

I'll go in website After looking at the problem, we found that the user did not use the Gutenberg editor to publish the article, but used the old editor. The wonderful thing about the old editor is that when you press the Enter key when editing the article, the editor will change lines, but there is no html tag, and the pure text will break lines. The tag "$post ->post_content" reads the body content of the article in the database directly. The background edited article is displayed as it is, so there is no line break.

 Wordpress calls the article content label and the article content does not break lines Solution Gutenberg Wordpress Wordpress Tutorial Page 1

What shall I do? In fact, the label "the_content()" is enough.

But something even more wonderful came. After the change, the website using the old editor displayed normally. The website using the Gutenberg editor output was empty, and I printed "the_content()" output was null.

So the question should be wordpress The upgrade span of the program version is too wide.


This is the end of this article, but in order to completely solve this problem, I searched how to determine whether the Gutenberg editor is enabled, and then output the corresponding tag according to this judgment.

Results After a search, it was found that Gutenberg did not exist as a plug-in, but was built in. This idea fails.

Finally, only one switch can be created. The user can set whether to enable it in the background and output the corresponding label according to the user's settings. The complete code is as follows:

backstage:

 If (get_option ('application ID ') ['gutenberg_on']=='0 '){ add_filter('use_block_editor_for_post', '__return_false');  // Disable Gutenberg Editor }

Reception:

 <? Php echo get_option ('Application ID ') ['gutenberg_on']=='1 '$ post->post_content : the_content();?>

This is barely usable.


Can't find a tutorial that can solve your problem?

You can try to search or ask questions directly online. We also provide charging technical support. If you need it, you can contact us online.

Online questions Online Service

welcome you Comment: Cancel Reply

 Please fill in the verification code
  • Latest articles
  • Hot article ranking
  • Most Comments
Label aggregation
  • Sign in
  • Registered account Forgot your password?
  • register
  • Already have an account? Direct login Forgot your password?
  • Social account login