WordPress.org

Make WordPress Core

Ticket #21485: 21485.diff

File 21485.diff, 908 bytes (added by DrewAPicture, 21 months ago)

Excludes current post

  • wp-includes/default-widgets.php

     
    562562                if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) 
    563563                        $number = 10; 
    564564 
    565                 $r = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) ); 
    566                 if ($r->have_posts()) : 
     565                $r = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'post__not_in' => array( get_the_ID() ) ) ) ); 
     566                if ( $r->have_posts() ) : 
    567567?> 
    568568                <?php echo $before_widget; ?> 
    569569                <?php if ( $title ) echo $before_title . $title . $after_title; ?>