I am very new in WordPress development and I have the folglowing problem.
I use this function (declared into the functions.php file of my theme) to modify the main query in such a way that the post having a specific tag are not displayed in my homepage:
function exclude_featured_tag_and_legacy_posts( $query ) {
$tagId = get_tag_ID("featured");
//echo("Featured Tag Id: + $tagId");
if ( $query->is_home() && $query->is_main_query() ) {
//$query->set( 'tag__not_in', 'array(ID OF THE FEATURED TAG)' );
$query->set( 'tag__not_in', array($tagId));
}
}
add_action( 'pre_get_posts', 'exclude_featured_tag' );
As you can see this function is executed after the main query creation but before its executions and it modify the main query for the exclusion of the posts that have the tag named featured
Ok, it seems work fine. Now my problem is. How can I further modify my main query so that is also excluded the posts belonging to a specific category?
So I want that is excluded both the posts having the featured tag and the posts belonging to the legacy category.
Can you help me?