1 | @@ -14,38 +14,37 @@ |
---|
2 | */ |
---|
3 | function render_block_core_latest_posts( $attributes ) { |
---|
4 | $args = array( |
---|
5 | - 'numberposts' => $attributes['postsToShow'], |
---|
6 | + 'posts_per_page' => $attributes['postsToShow'], |
---|
7 | 'post_status' => 'publish', |
---|
8 | 'order' => $attributes['order'], |
---|
9 | 'orderby' => $attributes['orderBy'], |
---|
10 | + 'suppress_filters' => false, |
---|
11 | ); |
---|
12 | |
---|
13 | if ( isset( $attributes['categories'] ) ) { |
---|
14 | $args['category'] = $attributes['categories']; |
---|
15 | } |
---|
16 | |
---|
17 | - $recent_posts = wp_get_recent_posts( $args ); |
---|
18 | + $recent_posts = get_posts( $args ); |
---|
19 | |
---|
20 | $list_items_markup = ''; |
---|
21 | |
---|
22 | foreach ( $recent_posts as $post ) { |
---|
23 | - $post_id = $post['ID']; |
---|
24 | - |
---|
25 | - $title = get_the_title( $post_id ); |
---|
26 | + $title = get_the_title( $post ); |
---|
27 | if ( ! $title ) { |
---|
28 | $title = __( '(Untitled)' ); |
---|
29 | } |
---|
30 | $list_items_markup .= sprintf( |
---|
31 | '<li><a href="%1$s">%2$s</a>', |
---|
32 | - esc_url( get_permalink( $post_id ) ), |
---|
33 | + esc_url( get_permalink( $post ) ), |
---|
34 | esc_html( $title ) |
---|
35 | ); |
---|
36 | |
---|
37 | if ( isset( $attributes['displayPostDate'] ) && $attributes['displayPostDate'] ) { |
---|
38 | $list_items_markup .= sprintf( |
---|
39 | '<time datetime="%1$s" class="wp-block-latest-posts__post-date">%2$s</time>', |
---|
40 | - esc_attr( get_the_date( 'c', $post_id ) ), |
---|
41 | - esc_html( get_the_date( '', $post_id ) ) |
---|
42 | + esc_attr( get_the_date( 'c', $post ) ), |
---|
43 | + esc_html( get_the_date( '', $post ) ) |
---|
44 | ); |
---|
45 | } |
---|
46 | |
---|