Exclude tag from module

Posted in: Newspaper
Post count: 10

Hello there,

we’re trying to exclude posts from a specific tag from showing up on block5.

We’re trying to use tag__not_in parameter on the query but no success.

How can we exclude posts from certain tags from showing up on certain blocks?

many thanks!

Post count: 20688

Hi,

You can filter the tags in each of the block setings – https://www.screencast.com/t/MAWzf7Z8VatB by entering only the tags allowed

Thanks

Post count: 10

Hello there,

Many thanks for the quick reply.

The problem is that we have thousands of tags and we want to include them all except one. We tried to do the same we did on categories add minus before the id but it seems not working on tags.

Now we were trying to change the query on those block phps to add tag__not_in but no luck.

We really appreciate all the help you can give, thanks!

Post count: 20688

Hi,

You can try this code and see if it works for you, you have to enter it in td_block_5.php file found in the theme folder->includes->shortcodes like this – https://www.screencast.com/t/bgBWwr7Hm9by

Example (replace with your tag id)

add_action( 'pre_get_posts', 'exclude_posts' );
function exclude_posts( $query ) {
$exclude_tags = array(247);
$query->set('tag__not_in',$exclude_tags);
}

Hope this works for you
Thanks

Post count: 10

Hello there,

Many thanks for all the help.

The exclusion is working, it’s allmost perfect, we only have one issue:
This action is excluding posts from the given tag from every shortcode/block not only from the block5. For example, we have one block 5 and then below a block 18. The excluded posts are also being excluded from block18.

we tried to use that action ad the module3.php but it’s not working well. Only exclude posts below that module.

Again, thanks for the time and help.

Post count: 20688

Hi,

Unfortunately I did not find an easy way of adapting the code to work only on one specific block using conditioning. Because this is a complex task, please consider hiring a freelancer/developer to help you in achieving this, as we cannot provide custom work at the moment, sorry.

Thank you for understanding

Viewing 6 posts - 1 through 6 (of 6 total)
The forum ‘Newspaper’ is closed to new topics and replies.