Creates a hidden taxonomy to improve expensive query performance by not relying on meta queries. Allows for 'flags' to be set/unset on posts easily and entirely hidden from the end-user.
By default, the internal taxonomy will be added to all registered post types.
- Hiding from archives/searches
- Posts by an author (where author is stored as a meta normally)
- Showing/hiding sponsored posts
use Internal_Flags\set_flag;
set_flag( 'hide-from-archives', $post_id );
use Internal_Flags\remove_flag;
remove_flag( 'hide-from-archives', $post_id );
use Internal_Flags\has_flag;
has_flag( 'hide-from-archives', $post_id ); // bool
use Internal_Flags\get_flag_tax_query;
$posts = new \WP_Query(
[
// ...
'tax_query' => [
get_flag_tax_query( 'show-on-page' )
],
],
);
Inverse of the above
use Internal_Flags\get_flag_tax_query;
$posts = new \WP_Query(
[
// ...
'tax_query' => [
get_flag_tax_query( 'hide-from-archives', false )
],
],
);