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 ) ) ); }