If the_content stop working after upgrading to WordPress 3

Well, this is one common problem happened after upgrading to WordPress 3. After upgrading to WordPress 3, the content is not displayed. This is happened likely because you don’t call the_post before you call the_content.

In previous version of WordPress, when we are on single/page, this worked fine. Some themes didn’t go into the WordPress loop on single/page template, since WordPress already know which page/post to show. This also make sense, single/page only have 1 post to be displayed, so we shouldn’t need to get into the WordPress loop. However, in the recent version, the_content failed to display anything if you don’t call the_post beforehand.

I’m not sure which one should be the correct behavior. In codex, it’s pretty clear that we still need to get into WordPress loop, even though we are in single/page template. However, in theory, calling the_post before calling any other function that supposed to be in the loop should fix it.

Just a quick note, I don’t want to forgot this trivial stuff when I got this problem again in future. 🙂

3 comments | Leave a comment

  1. rob lynch October 1, 2010 22:46

    Thank you very much!! I was following a tutorial that built a singepage.php file – it called the_content() but not the_post().. of course nothing showed up..

    You saved many hours of frustration!

  2. Prasad May 30, 2011 16:41

    Nice article.

    Visit http://www.wordpressstop.com for more articles related to WordPress.

    keep Smiling

  3. Sushil October 21, 2011 17:41

    Thanks a lot,
    How you find the solution ??

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.