# gutenberg/23.6.2/lib/compat/wordpress-7.1/query-block.php

Gutenberg, version 23.6.2. 28 lines.

- Page: https://pluginprobe.com/plugins/gutenberg/23.6.2/code/lib/compat/wordpress-7.1/query-block.php
- Raw: https://pluginprobe.com/plugins/gutenberg/23.6.2/raw/lib/compat/wordpress-7.1/query-block.php
- Modified: 2026-07-22T11:19:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/gutenberg/23.6.2/code/lib/compat/wordpress-7.1/query-block.php#L10-L20`.

```php
<?php
/**
 * Temporary compatibility code for new functionalities/changes related to the query block.
 *
 * @package gutenberg
 */

/**
 * Filters the query loop block query vars to exclude the current post.
 *
 * @param array $query The current query vars.
 * @param WP_Block $block The block instance.
 *
 * @return array The modified query vars.
 */
function gutenberg_filter_query_block_exclude_current( $query, $block ) {
	if ( ! empty( $block->context['query']['excludeCurrent'] ) ) {
		$current_post_id = get_the_ID();
		if ( $current_post_id ) {
			$query['post__not_in'][] = $current_post_id;
		}
	}

	return $query;
}

add_filter( 'query_loop_block_query_vars', 'gutenberg_filter_query_block_exclude_current', 10, 2 );

```
