WordPress.org

Forums

[resolved] $post->post_content coming up blank (6 posts)

  1. marcusds
    Member
    Posted 5 years ago #

    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?

  2. keesiemeijer
    moderator
    Posted 5 years ago #

    could you show us the code of the whole loop?

  3. marcusds
    Member
    Posted 5 years ago #

    <?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. ?>
  4. keesiemeijer
    moderator
    Posted 5 years ago #

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

  5. marcusds
    Member
    Posted 5 years ago #

    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.

  6. keesiemeijer
    moderator
    Posted 5 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic