• Resolved NWTD

    (@nwtechie)


    I’m trying to list the 10 most recent posts on a particular page.

    I’m using the TwentyEleven theme and using the following code:

    <ul>
    		<?php
    			global $post;
    			$args = array( 'numberposts' => 10 );
    			$myposts = get_posts( $args );
    			foreach( $myposts as $post ) :	setup_postdata($post); ?>
    			<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    		<?php endforeach; ?>
    	</ul>

    When I do this, I loose all the content on the page. It is replace by the content of the last post in the list.

    I assume there is a quick simple fix for this to reset the wp_query or something…I’m just not sure.

    Any help would be greatly appreciated. TIA

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display list of recent posts on page’ is closed to new replies.