Plugin Author
TC.K
(@wp_dummy)
Do you mean the default category or custom taxonomy?
Thread Starter
Josiah
(@colewebdev)
Category. I’d like the results to pull from a specific post type (already done) AND category.
For example my custom post type is “listings” and it uses the default categories. I want my search results to only show listing post from a specific category (say for example “lodging”)
I would like to do this per form, so that I can make more than one search form that searches different categories/post types.
Hello, i’m also interested in an answer.
Actually i’m using this system and i need the category ID to be send within the form.
For example when i’m on a specific category the GET value of “cat” is 53
( ?cat=53 )
And when i press search on the form in this specific category, the search is done but “cat” value doesn’t exist anymore in the new page.
I don’t know if such a thing already exist in your plugin ?
Plugin Author
TC.K
(@wp_dummy)
You can inject ‘category__not_in‘ parameter to the argument filter.
Depends on the result template, if it is default template, you should use uwpqsf_deftemp_query()
filter. If Ajax, use wpqsf_query_args()
.
Example of use:
add_filter('wpqsf_query_args','exclude_cat_uwpqsf','', 3);
function exclude_cat_uwpqsf($args, $id,$getdata){
$args['category__not_in'] = array(53,12,45);
return $args;
}
Thread Starter
Josiah
(@colewebdev)
Not sure I follow, how do I use category_not_in to specify which category the search form uses?
Plugin Author
TC.K
(@wp_dummy)
You can use the form id ($id) for conditional check.
Eg.
function exclude_cat_uwpqsf($args, $id,$getdata){
if($id == '123') //123 is your form id{
$args['category__not_in'] = array(53,12,45);}
if($id=='234'){
$args['category__not_in'] = array(1,2,35);
}
return $args;
}