get_post post_excerpt not displaying (4 posts)

  1. negs
    Posted 6 years ago #

    I am using get_post() to display an array of post ids.

    I am using it properly. I can get

    $title = $post_id->post_title;
    echo $title;

    to display the title of the post.

    However, when I try

    $excerpt = $post_id->post_excerpt;
    echo $excerpt;

    nothing is displayed. There is content in the post, and I can display when I use post_content. But I want the excerpt because I want to filter out the images in the post.

    Any advice?

  2. MichaelH
    Posted 6 years ago #

    //display all post titles, and if an excerpt exists, show it
    if ($posts) {
      foreach($posts as $post) {
        <p><?php the_time('m.d.y') ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        if ($post->post_excerpt) {
          echo 'excerpt is:' . $post->post_excerpt;

    Note that echo $post->post_excerpt; would also work

  3. negs
    Posted 6 years ago #

    I forgot to say... thanks for the reply! I ended up doing something totally different because of a last minute design change. But this was helpful to see.

  4. abmcr
    Posted 5 years ago #

    I am also using get_post() to display a single page

    $pagina = & get_post( $dummy_id = 6 );?>
    <h2><?php echo $pagina->post_title;?></h2>
    <?php echo $pagina->post_content; ?>

    However, if i want to show only the text before my page break.... how i do?

Topic Closed

This topic has been closed to new replies.

About this Topic