Why is the_content() not displaying the content?

admin2025-06-02  2

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 12 years ago.

in my wordpress site, the_content() is not showing the content, but $post->post_content shows it, why this is happening? and how can I use the_content again?

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 12 years ago.

in my wordpress site, the_content() is not showing the content, but $post->post_content shows it, why this is happening? and how can I use the_content again?

Share Improve this question edited Mar 2, 2012 at 3:59 Brian Fegter 10k1 gold badge42 silver badges60 bronze badges asked Mar 2, 2012 at 2:54 srisarsrisar 2611 gold badge3 silver badges6 bronze badges 5
  • 2 What is the code that surrounds that? Are you in the loop? – mor7ifer Commented Mar 2, 2012 at 2:58
  • What Theme are you using? If it is a custom Theme, then we will need to see the custom code for the template file in question. – Chip Bennett Commented Mar 2, 2012 at 3:24
  • I got on one of those problem. I believe it occurs due to a another WP_Query made before the_content(). – ifdion Commented Mar 2, 2012 at 11:10
  • Happened to me when upgrading to WP5 – Fanky Commented Jun 28, 2019 at 11:59
  • I don't why this is marked as unlikely to help future visitors - it's a good question and has useful answers. This doesn't seem any more "extraordinarily narrow" than any other question on WordPress Stack Exchange. – JohnG Commented Jul 31, 2020 at 12:10
Add a comment  | 

3 Answers 3

Reset to default 10

In order to use "the_content()" it must be used within The Loop.

See here: http://codex.wordpress/Function_Reference/the_content

"Displays the contents of the current post. This tag must be within The_Loop."

If it worked before, it's probably a plugin hooking into the_content filter. Disable your plugins one by one to see if this fixes the issue. Next, check the callback functions for the_content filter.

You can see every callback for the_content by adding the following:

add_action('template_redirect', 'wpse_44152_template_redirect');
function wpse_44152_template_redirect(){
    global $wp_filter;
    print_r($wp_filter['the_content']);
}

Find each of the functions listed by doing a 'find in files' code search on your code editor. A filter callback HAS TO return $content data back for the_content() to work properly.

you can check your functions.php in your theme folder,find if some function do something for the "the_content" function.my theme have the same problem,and I found a function has a mistake and cause "the_content" can't work

find text like "the_content" in your functions.php,

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748819078a313986.html

最新回复(0)