| @@ -36,13 +36,14 @@ | ||
| 36 | 36 | function gutenberg_render_block_core_latest_posts( $attributes ) { |
| 37 | 37 | global $post, $block_core_latest_posts_excerpt_length; |
| 38 | 38 | |
| 39 | 39 | $args = array( |
| 40 | - 'posts_per_page' => $attributes['postsToShow'], | |
| 41 | - 'post_status' => 'publish', | |
| 42 | - 'order' => $attributes['order'], | |
| 43 | - 'orderby' => $attributes['orderBy'], | |
| 44 | - 'suppress_filters' => false, | |
| 40 | + 'posts_per_page' => $attributes['postsToShow'], | |
| 41 | + 'post_status' => 'publish', | |
| 42 | + 'order' => $attributes['order'], | |
| 43 | + 'orderby' => $attributes['orderBy'], | |
| 44 | + 'ignore_sticky_posts' => true, | |
| 45 | + 'no_found_rows' => true, | |
| 45 | 46 | ); |
| 46 | 47 | |
| 47 | 48 | $block_core_latest_posts_excerpt_length = $attributes['excerptLength']; |
| 48 | 49 | add_filter( 'excerpt_length', 'gutenberg_block_core_latest_posts_get_excerpt_length', 20 ); |
| @@ -53,10 +54,15 @@ | ||
| 53 | 54 | if ( isset( $attributes['selectedAuthor'] ) ) { |
| 54 | 55 | $args['author'] = $attributes['selectedAuthor']; |
| 55 | 56 | } |
| 56 | 57 | |
| 57 | - $recent_posts = get_posts( $args ); | |
| 58 | + $query = new WP_Query(); | |
| 59 | + $recent_posts = $query->query( $args ); | |
| 58 | 60 | |
| 61 | + if ( isset( $attributes['displayFeaturedImage'] ) && $attributes['displayFeaturedImage'] ) { | |
| 62 | + update_post_thumbnail_cache( $query ); | |
| 63 | + } | |
| 64 | + | |
| 59 | 65 | $list_items_markup = ''; |
| 60 | 66 | |
| 61 | 67 | foreach ( $recent_posts as $post ) { |
| 62 | 68 | $post_link = esc_url( get_permalink( $post ) ); |
| @@ -104,9 +110,9 @@ | ||
| 104 | 110 | ); |
| 105 | 111 | } |
| 106 | 112 | |
| 107 | 113 | $list_items_markup .= sprintf( |
| 108 | - '<a href="%1$s">%2$s</a>', | |
| 114 | + '<a class="wp-block-latest-posts__post-title" href="%1$s">%2$s</a>', | |
| 109 | 115 | esc_url( $post_link ), |
| 110 | 116 | $title |
| 111 | 117 | ); |
| 112 | 118 | |