Exclude posts with a tag from category

Support reply may delay for 3 weeks due to corona virus outbreak, please send us email to support@pickplugins.com
0
dveersel
Dec 31, 2017 08:11 AM 1 Answers General
Member Since Dec 2017
Subscribed Subscribe Not subscribe
Flag(0)

I want to create a Post Grid for all posts with (for example) category A, but exclude the ones that have (for example) tag 1. How do I set up the grid so that I can exclude certain posts based on their tag?

2 Subscribers
Submit Answer
Please login to submit answer.
1 Answers
Sort By:
Best Answer
0
PickPlugins
Dec 31, 2017
Flag(0)

Welcome to our forum.

I can see currently you can’t query like this way you are looking for, although you can use filter hook for query arguments, please see the documentation here

Filters – post_grid_filter_query_args

https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

Let me know for more help.

Regards

dveersel
- Dec 31, 2017 02:28 PM
Flag (0)
0

Thanks for the help. I tried to write a custom CSS script based on this, but it is not working for me (yet):

function post_grid_filter_query_args_extra($query_args, $grid_id){

if($grid_id==71256){
$extra_query = array (
'tag__not_in' => array('1283'),
);
$query_args = array_merge($query_args, $extra_query);
}
return $query_args;
}
add_filter('post_grid_filter_query_args','post_grid_filter_query_args_extra',10,2);

dveersel
- Dec 31, 2017 02:28 PM
Flag (0)
0

Thanks for the help. I tried to write a custom CSS script based on this, but it is not working for me (yet):

function post_grid_filter_query_args_extra($query_args, $grid_id){

if($grid_id==71256){
$extra_query = array (
'tag__not_in' => array('1283'),
);
$query_args = array_merge($query_args, $extra_query);
}
return $query_args;
}
add_filter('post_grid_filter_query_args','post_grid_filter_query_args_extra',10,2);

Sign in to Reply
Replying as Submit

Please use https://imgur.com/upload to upload your screenshot and share url here.
You can't upload any files or attachment to our server directly for security reason, you can use 3rd party website and share file url here. here is the top file sharing website you can use.

Please login to see your tickets