Forums

get recent post (4 posts)

  1. chilibird
    Member
    Posted 2 years ago #

    Hi,

    I would like to have an excerpt of my recent post listed in the sidebar widget "recent post" Currently it list the title only

    Can anyone help?

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

  3. chilibird
    Member
    Posted 2 years ago #

    thanks emsi, but I want to show excerpts, not just the listed item. is that possible? I found a plugin "recent-post with excerpt" that I am going to try.

  4. MichaelH
    Volunteer
    Posted 2 years ago #

    Put this in a PHP Code Widget:

    <?php
    $args=array(
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => 10,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
        the_excerpt();
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic