Код: Выделить всё
// Add Column to admin post list
function custom_columns_list( $columns ) {
$columns['blockBool'] = 'Block Present?';
return $columns;
}
add_filter( 'manage_post_posts_columns', 'custom_columns_list' );
// check post if block is present
function blockColumn() {
//using a block from learn.wordpress
if ( has_block( 'create-block/multi-columns' ) ) {
// echo '
True
';
$blockBool = "True";
echo "$blockBool";
} else {
// echo '
False
';
$blockBool = "False";
echo "$blockBool";
}
}
add_action( 'manage_posts_custom_column', 'blockColumn', 10, 2 );
// add filter drop down to post admin list
function blockCheckFilter( $post_type ) {
if ( $post_type === 'post' ) {
$blockBool = filter_input( INPUT_GET, 'blockBool' );
?>
Block Present?
>False
Подробнее здесь: [url]https://stackoverflow.com/questions/79565297/wordpress-filter-posts-if-a-specific-custom-block-is-present-on-post[/url]
Мобильная версия