diff --git a/packages/block-library/src/latest-posts/index.php b/packages/block-library/src/latest-posts/index.php index 18a43e51828e56..0b0d858bbfe5e4 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( '