Support » Fixing WordPress » $post->post_content coming up blank

  • Resolved marcusds

    (@marcus1060)


    OK, weird problem. Inside a loops on a page-XX.php, I can do a print_r($post). And see all the elements in the object, including the content in post_content, however as soon as I try to echo $post->post_content it comes up blank, same with $post-ID or anything else! I really don’t get it. Can anyone help?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    could you show us the code of the whole loop?

    <?php
    if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <?php
    print_r($post);
    print $post–>post_content;
    ?>
    </div>
    <?php endwhile; // end of the loop. ?>
    Moderator keesiemeijer

    (@keesiemeijer)

    You have a wrong character in the “->” part.
    yours: print $post–>post_content;
    and how it should be: print $post->post_content;

    Ha, I blame WordPress for how it formated it on the blog I copied that from!

    Thanks for the help! I was looking at it for far too long.

    Moderator keesiemeijer

    (@keesiemeijer)

    Glad to be of help. That was a very subtle difference. Can you make this topic resolved.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘$post->post_content coming up blank’ is closed to new replies.