Exclude posts on category with certain tags…

Posted in: Newsmag
Post count: 27

Hello there, great theme! I’ve had no problems as of yet and I’ve done quite a bit with it so far!

However I am stuck. My site has a expired tag that we use to hide posts on category pages that have this expired tag.

We used something like this on our old theme to hide specific tagged posts from category / loop.

$exclude_tags = array(6725);
$wp_query->set(‘tag__not_in’,$exclude_tags);

However I cannot get it to work on this theme.

Can an admin help me out here?

Thanks!

Post count: 6600

Hi,

The theme uses different arguments than the ones wordpress uses and the so you would have to consider that, you can find the function here: http://screencast.com/t/XQSUUzLOXp6

Thanks

Post count: 27

I added:

‘tag__not_in’=> ‘6725’,

to

‘category_ids’ => ”,
‘category_id’ => ”,
‘tag_slug’ => ”,
‘sort’ => ”,
‘limit’ => ”, /*’limit’ => 5,*/
‘autors_id’ => ”,
‘installed_post_types’ => ”,
‘posts_per_page’ => ”,
‘offset’ => ”,
‘live_filter’ => ”,
‘live_filter_cur_post_id’ => ”, //this is auto generated by the block render ( add_live_filter_atts ) only when it’s needed – it’s the current post id
‘live_filter_cur_post_author’ => ” //auto generated – author_id of current post

Still no luck with having those expired tagged posts being removed from category.

  • This reply was modified 11 years by SaL.
Post count: 6600

Hi,

Try this: http://screencast.com/t/yUVJMSwbvII

add_action( 'pre_get_posts', 'exclude_posts' );
function exclude_posts( $query ) {
$exclude_tags = array(32);

if(is_category()) {
$query->set('tag__not_in',$exclude_tags);
}
}

Thanks

Post count: 27

Works perfectly!

Thanks a lot Lucian!

Congrats guys on such an awesome theme!

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