Reputation: 13
I have succeeded in excluding certain categories from my blogpage by editing the function.php, however i cannot seem to exclude all posts with tag id 113 from my blog. Can anyone help me out by pointing out which code i should use? Thanks in advance, Best regards,
Upvotes: 1
Views: 258
Reputation: 545
you can use the code:
if(!has_tag(113))
{
//Display your posts
}
The above code should be used inside the Wordpress loop.
==> In order to filter your posts inside functions.php you can use "pre_get_posts" hook:
function exclude_tag($query)
{
if ($query->is_main_query()) {
$query->set('tag__not_in', array( '113' ));
}
}
add_action('pre_get_posts', 'exclude_tag');
Upvotes: 2