In GenesisWP Slack channel, a user asked:
Using the inbuilt Genesis Featured Posts, is there a way to exclude a specific tag from the results? Wondering if there’s a way using pre_get_posts…
So posts with a specific tag don’t show in genesis featured post widgets.
This can be done using Custom Genesis Featured Posts Widget plugin.
Step 1
Install and activate Custom Genesis Featured Posts Widget plugin.
Step 2
Modify plugin’s class-custom-featured-post.php
.
Locate
$query_args = array(
'post_type' => 'post',
'cat' => $instance['posts_cat'],
'showposts' => $instance['posts_num'],
'offset' => $instance['posts_offset'],
'orderby' => $instance['orderby'],
'order' => $instance['order'],
'ignore_sticky_posts' => $instance['exclude_sticky'],
);
and add tag__not_in
like so:
$query_args = array(
'post_type' => 'post',
'cat' => $instance['posts_cat'],
'showposts' => $instance['posts_num'],
'offset' => $instance['posts_offset'],
'orderby' => $instance['orderby'],
'order' => $instance['order'],
'ignore_sticky_posts' => $instance['exclude_sticky'],
'tag__not_in' => array( 24 ),
);
where 24 is the ID of the tag to be excluded from the Genesis Featured Posts.
That’s it.
[post_tags] shortcode can be used to display tags in the plugin’s widget settings.
References
https://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters
Would it be possible with ‘pre_get_posts’ where you would check for some values in the query args and only add a ‘tag__not_in’ in certain cases.
Not in the query for Genesis Featured Posts widgets, as far as I know.