You should replace your query
-
Actually, when you apply the filter query_loop_block_query_vars on pre_render_block, all the query after your block will be affected.
You should instead use the hook outside pre_render_block, and fetch your conditions inside this hook :add_filter( 'query_loop_block_query_vars', __NAMESPACE__ . '\filter_my_query', 10, 2 ); function filter_my_query( $query, $block ) { if ( isset( $block->parsed_block['attrs']['namespace'] ) && 'creativeandrew/single-post-query-loop-selector' === $block->parsed_block['attrs']['namespace'] ) { if ( isset( $block->parsed_block['attrs']['query']['include'] ) ) { $query['post__in'] = $block->parsed_block['attrs']['query']['include']; } } return $query; }
Have a nice day !
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘You should replace your query’ is closed to new replies.