From c7a8c1247ce9e6b6f4d8364c2370873578a23b3a Mon Sep 17 00:00:00 2001 From: Sergey Date: Thu, 7 Feb 2019 10:14:54 +0200 Subject: [PATCH] =?UTF-8?q?render=5Fblock=5Fcore=5Flatest=5Fposts()=20use?= =?UTF-8?q?=20get=5Fposts()=20instead=20of=20wp=5Fget=5Frecen=E2=80=A6=20(?= =?UTF-8?q?#11984)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * render_block_core_latest_posts() use get_posts() instead of wp_get_recent_posts() * small fix * small fix --- .../block-library/src/latest-posts/index.php | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/block-library/src/latest-posts/index.php b/packages/block-library/src/latest-posts/index.php index 18a43e51828e5..0b0d858bbfe5e 100644 --- a/packages/block-library/src/latest-posts/index.php +++ b/packages/block-library/src/latest-posts/index.php @@ -14,38 +14,37 @@ */ function render_block_core_latest_posts( $attributes ) { $args = array( - 'numberposts' => $attributes['postsToShow'], - 'post_status' => 'publish', - 'order' => $attributes['order'], - 'orderby' => $attributes['orderBy'], + 'posts_per_page' => $attributes['postsToShow'], + 'post_status' => 'publish', + 'order' => $attributes['order'], + 'orderby' => $attributes['orderBy'], + 'suppress_filters' => false, ); if ( isset( $attributes['categories'] ) ) { $args['category'] = $attributes['categories']; } - $recent_posts = wp_get_recent_posts( $args ); + $recent_posts = get_posts( $args ); $list_items_markup = ''; foreach ( $recent_posts as $post ) { - $post_id = $post['ID']; - - $title = get_the_title( $post_id ); + $title = get_the_title( $post ); if ( ! $title ) { $title = __( '(Untitled)' ); } $list_items_markup .= sprintf( '
  • %2$s', - esc_url( get_permalink( $post_id ) ), + esc_url( get_permalink( $post ) ), esc_html( $title ) ); if ( isset( $attributes['displayPostDate'] ) && $attributes['displayPostDate'] ) { $list_items_markup .= sprintf( '', - esc_attr( get_the_date( 'c', $post_id ) ), - esc_html( get_the_date( '', $post_id ) ) + esc_attr( get_the_date( 'c', $post ) ), + esc_html( get_the_date( '', $post ) ) ); }