diff --git src/wp-includes/widgets/class-wp-widget-recent-posts.php src/wp-includes/widgets/class-wp-widget-recent-posts.php
index c8d19055b4..37843c3a8b 100644
|
|
|
class WP_Widget_Recent_Posts extends WP_Widget { |
| 51 | 51 | $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
| 52 | 52 | |
| 53 | 53 | $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; |
| 54 | | if ( ! $number ) |
| | 54 | if ( ! $number ) { |
| 55 | 55 | $number = 5; |
| | 56 | } |
| 56 | 57 | $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; |
| 57 | 58 | |
| 58 | 59 | /** |
| … |
… |
class WP_Widget_Recent_Posts extends WP_Widget { |
| 70 | 71 | 'posts_per_page' => $number, |
| 71 | 72 | 'no_found_rows' => true, |
| 72 | 73 | 'post_status' => 'publish', |
| 73 | | 'ignore_sticky_posts' => true |
| | 74 | 'ignore_sticky_posts' => true, |
| 74 | 75 | ), $instance ) ); |
| 75 | 76 | |
| 76 | | if ($r->have_posts()) : |
| | 77 | if ( ! $r->have_posts() ) { |
| | 78 | return; |
| | 79 | } |
| 77 | 80 | ?> |
| 78 | 81 | <?php echo $args['before_widget']; ?> |
| 79 | | <?php if ( $title ) { |
| | 82 | <?php |
| | 83 | if ( $title ) { |
| 80 | 84 | echo $args['before_title'] . $title . $args['after_title']; |
| 81 | | } ?> |
| | 85 | } |
| | 86 | ?> |
| 82 | 87 | <ul> |
| 83 | | <?php while ( $r->have_posts() ) : $r->the_post(); ?> |
| 84 | | <li> |
| 85 | | <a href="<?php the_permalink(); ?>"><?php get_the_title() ? the_title() : _e( '(no title)' ); ?></a> |
| 86 | | <?php if ( $show_date ) : ?> |
| 87 | | <span class="post-date"><?php echo get_the_date(); ?></span> |
| 88 | | <?php endif; ?> |
| 89 | | </li> |
| 90 | | <?php endwhile; ?> |
| | 88 | <?php foreach ( $r->posts as $recent_post ) : ?> |
| | 89 | <?php |
| | 90 | $post_title = get_the_title( $recent_post->ID ); |
| | 91 | $title = ( ! empty( $post_title ) ) ? $post_title : __( '(no title)' ); |
| | 92 | ?> |
| | 93 | <li> |
| | 94 | <a href="<?php the_permalink( $recent_post->ID ); ?>"><?php echo $title ; ?></a> |
| | 95 | <?php if ( $show_date ) : ?> |
| | 96 | <span class="post-date"><?php echo get_the_date( '', $recent_post->ID ); ?></span> |
| | 97 | <?php endif; ?> |
| | 98 | </li> |
| | 99 | <?php endforeach; ?> |
| 91 | 100 | </ul> |
| 92 | | <?php echo $args['after_widget']; ?> |
| 93 | 101 | <?php |
| 94 | | // Reset the global $the_post as this query will have stomped on it |
| 95 | | wp_reset_postdata(); |
| 96 | | |
| 97 | | endif; |
| | 102 | echo $args['after_widget']; |
| 98 | 103 | } |
| 99 | 104 | |
| 100 | 105 | /** |