• marenm

    (@marenm)


    Hi there,

    I’m using the wp_get_recent_posts to add a custom recent posts thing to my child theme.
    I’ve got the title/permalink showing up but can’t get the date or the excerpt. Is this even possible with wp_get_recent_posts?

    If someone could steer me in the right direction that would be much appreciated.

    thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • fishfinder

    (@fishfinder)

    Try this:

    <?php
     $postslist = get_posts('numberposts=3&order=DESC&orderby=date');
     foreach ($postslist as $post) :
        setup_postdata($post);
     ?>
     <div class="entry">
     <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
     <?php the_time(get_option('date_format')) ?>
     <?php the_excerpt(); ?>
     </div>
     <?php endforeach; ?>
    Thread Starter marenm

    (@marenm)

    Thanks! That did work, at least most of the way.
    However, instead of the post title, for some it just displays “Home.”
    Very strange. Any thoughts?
    Here is my code (almost identical)

    //Call Recent Posts
    		function recentpostcycle() { ?>
    			<div class="cycleNewsPosts">
    				<ul>
    					<?php
    					$args = array( 'numberposts' => 10, 'order' => 'ASC', 'category_name' => 'news');
    					 $postslist = get_posts( $args);
    					 foreach ($postslist as $post) :
    					    setup_postdata($post);
    					 ?>
    					 <li class="entry">
    					 <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    					 <?php the_time(get_option('date_format')) ?>
    					 <?php the_excerpt(); ?>
    					 </li>
    					 <?php endforeach; ?>
    				</ul>
    			</div>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘displaying date and excerpt with wp_get_recent_posts ?’ is closed to new replies.