diff --git a/php/Block.php b/php/Block.php index b5aab89..10b3071 100644 --- a/php/Block.php +++ b/php/Block.php @@ -8,6 +8,7 @@ namespace XWP\SiteCounts; use WP_Block; +use WP_Query; /** * The Site Counts dynamic block. @@ -63,28 +64,89 @@ public function register_block() { */ public function render_callback( $attributes, $content, $block ) { $post_types = get_post_types( [ 'public' => true ] ); - $class_name = $attributes['className']; + $class_name = $block->block_type->attributes['className']; ob_start(); ?> -
+ +
+ $post_type_slug, - 'posts_per_page' => -1, - ] - ) - ); + $query = new WP_Query( + ( [ + 'post_type' => [ 'post', 'page' ], + 'post_status' => 'any', + 'date_query' => ( [ + ( [ + 'hour' => 9, + 'compare' => '>=', + ] ), + ( [ + 'hour' => 17, + 'compare' => '<=', + ] ), + ] ), + 'tag' => 'foo', + 'category_name' => 'baz', + 'post__not_in' => [ get_the_ID() ], + ] ) + ); + if ( $query->found_posts ) : ?> -labels->name . '.'; ?>
- - +