diff --git a/php/Block.php b/php/Block.php index 0d1d2a6..4f449c4 100644 --- a/php/Block.php +++ b/php/Block.php @@ -63,37 +63,62 @@ public function register_block() { * @return string The markup of the block. */ public function render_callback( $attributes, $content, $block ) { - $post_types = get_post_types( [ 'public' => true ] ); - $class_name = $attributes['className']; - ob_start(); + $exclude = array( get_the_ID() ); + $class_name = ''; + $post_types = get_post_types( array( 'public' => true ) ); + if ( isset( $attributes['className'] ) && ! empty( $attributes['className'] ) ) : + $class_name = $attributes['className']; + endif; + ob_start(); ?> -
+ +
['post', 'page'], - 'post_status' => 'any', - 'date_query' => array( + $query = new WP_Query( array( + 'post_type' => array( 'post', 'page' ), + 'posts_per_page' => 5 + count( $exclude ), + 'post_status' => 'any', + 'no_found_rows' => true, + 'update_post_meta_cache' => false, + 'update_post_term_cache' => false, + 'fields' => 'ids', + 'date_query' => array( array( 'hour' => 9, 'compare' => '>=', @@ -103,24 +128,27 @@ public function render_callback( $attributes, $content, $block ) { 'compare'=> '<=', ), ), - 'tag' => 'foo', - 'category_name' => 'baz', - 'post__not_in' => [ get_the_ID() ], - 'meta_value' => 'Accepted', - )); + ) ); - if ( $query->found_posts ) : + if ( $query->have_posts() ) : + ?> + +