Forums

Getting latest post exerpt in a widget on a page (4 posts)

  1. chriswinsatlife
    Member
    Posted 2 years ago #

    Hey, I am trying to get my latest post to show up with an image on my about page.

    The components I want to show up are: the title (with permalink), the excerpt (truncated), the photo (if present), and the metadata.

    I entered the code below, but simply got the text of the page itself rather than the latest post.

    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title() ?></a></h6>
    <?php get_the_image( array( 'custom_key' => array( 'thumbnail' ), 'default_size' => 'thumbnail', 'width' => '310', 'height' => '150' ) ); ?>
    <?php the_excerpt(); ?>
    <p class="postmetadata"><?php the_time('M d, Y') ?> | <?php comments_popup_link('Have your say »', '1 Comment »', '% Comments »'); ?></p>

    Thanks for the help.

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

  3. chriswinsatlife
    Member
    Posted 2 years ago #

    Yeah so that in no way answers my question. My code is grabbing pages instead of posts and I'm not sure why, while nothing on that page you've linked addresses the issue.

  4. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Doesn't matter if you're grabbing posts or pages. The approach is the same. Only the parameters in your additional Loops or in get_posts vary.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags