AnonymousInactive
OK,
I’m able to get this to filter:
function member_query_args( $query_args, $sfid ) {
if($sfid==3906) {
$query_args = array(
‘member-category’ => ‘hotels-motels’
);
}
return $query_args;
}
How can I go about dynamically placing the value of member-category ?
add_filter( ‘sf_edit_query_args’, ‘member_query_args’, 10, 2 );
AnonymousInactive
Hello Support,
I’m trying to filter search results based on a taxonomy item. I’m trying to this code that I found in the forum, but I can’t get it to work even just using $query_args[‘order’] = ‘desc’;
What am I doing wrong here? Below is the the code I’ve been trying.
function sf_filter_query_args( $query_args, $sfid ) {
if($sfid==3906) {
$query_args[‘member-category’] = get_queried_object()->name;
//$query_args[‘order’] = ‘desc’;
}
return $query_args;
}
add_filter( ‘sf_edit_query_args’, ‘sf_filter_query_args’, 10, 2 );
Hi Sergey
Its just the same as the $args
object you pass to a new WP_Query
– so this link should provide you with the necessary options:
https://codex.wordpress.org/Class_Reference/WP_Query
To take their category example and apply it to the S&F filter:
https://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters
=
<?php
function sf_filter_query_args( $query_args, $sfid ) {
//if search form ID = 225, the do something with this query
if($sfid==225)
{
//modify $query_args here before returning it
//only show results within categories with these IDs
$query_args['cat'] = '2,6,17,38';
}
return $query_args;
}
add_filter( 'sf_edit_query_args', 'sf_filter_query_args', 10, 2 );
?>
Thanks