/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
lib/compat/wordpress-7.1/query-block.php
27 строк
729 B
Gareth Elwell
Add option to exclude current post from query block (#64916)
13 июл 2026, 05:10
Не верифицирован
13 июл 2026, 05:10
8be2862
Код
Авторство
О чём код?
<?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 );