[wp-trac] [WordPress Trac] #21485: Twenty Twelve: Exclude Present Post From Recent Post

WordPress Trac wp-trac at lists.automattic.com
Sun Aug 5 23:16:57 UTC 2012


#21485: Twenty Twelve: Exclude Present Post From Recent Post
---------------------------+-----------------------------
 Reporter:  Asif2BD        |      Owner:
     Type:  enhancement    |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Bundled Theme  |    Version:
 Severity:  normal         |   Keywords:  ux-feedback
---------------------------+-----------------------------
 Checking demo site - http://twentytwelvedemo.wordpress.com/

 If you visit any recent post like this one -
 http://twentytwelvedemo.wordpress.com/2012/03/28/road-trips/

 The recent post widget on right sidebar include this post in recent 5
 post. We could just exclude present post from the loop using code like
 this



 {{{
 <?php
                                 global $post;
                                 $args=array(
                                         "numberposts"=>5,
                                         "orderby"=>"post_date",
                                         "post__not_in"=>array($post->ID)
                                 );

                                 $posts = get_posts($args);

                                 foreach($posts as $post) {
                                         setup_postdata($post);
 ?>
 }}}

 Most theme has it. If you are already in a post which is among recent 5,
 no point of showing it in the loop.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21485>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list