From e29508610355aedb1392fe6635fa967828e9f4ee Mon Sep 17 00:00:00 2001 From: James Amner Date: Mon, 19 Aug 2024 11:21:33 +0100 Subject: [PATCH] [FIX] Frontend Rendering Quer --- .../query-include-exclude/query-include-exclude.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/query-include-exclude/query-include-exclude.php b/packages/query-include-exclude/query-include-exclude.php index 30974ae..df20978 100644 --- a/packages/query-include-exclude/query-include-exclude.php +++ b/packages/query-include-exclude/query-include-exclude.php @@ -28,3 +28,16 @@ function () { ); } ); + +add_filter( + 'query_loop_block_query_vars', + function ( array $query, \WP_Block $block ): array { + $block_query = $block->context['query'] ?? array(); + if ( ! empty( $block_query['include'] ) ) { + $query['post__in'] = array_map( 'intval', $block_query['include'] ); + } + return $query; + }, + 10, + 2 +);