The forums are closed and will be removed when we launch our new site.
Looking for support? You can access the support system via your account.
The forums are closed and will be removed when we launch our new site.
Looking for support? You can access the support system via your account.
Hi Ross,
Thank you for this, it worked straight away.
Dan
Hi Trevor,
I have specified the post type in the search form setup but sadly the code didn’t work.
I am showing the results using a shortcode, would that make any difference?
Thanks
Sadly that hasn’t worked.
I am using a custom post type called artist though so do I not need to specify that too?
Thanks
Hi,
Below is the code snippet I have used but it doesn’t seem to be working. I get ‘No results found’. Can you see anything obviously wrong with it?
function filter_function_name( $query_args, $sfid ) {
//if search form ID = 264, the do something with this query
if($sfid==264) {
//modify $query_args here before returning it
// $query_args['somearg'] = 'newvalue';
$postid = get_the_ID();
$query_args = array(
'post_type' => 'artist',
'post__not_in' => $postid,
);
}
return $query_args;
}
add_filter( 'sf_edit_query_args', 'filter_function_name', 20, 2 );
I think I have managed to figure it out (I should’ve been more patient). I wasn’t using the Post Meta options properly. I have now set it as follows:
featured (my ACF meta) – char – equals – 0
So this form now returns all results that aren’t featured
Okay thank you. I am using the shortcode method so it appears to be working so far.
I have another question though. I followed your instructions on another post about creating featured posts (https://support.searchandfilter.com/forums/topic/featured-posts/). I have got one of the search forms displaying the featured posts, is there a way to hide featured posts from another search form?
It seems the Post Meta options in Settings & Defaults might do what I am after but I can’t seem to get it to work.
Thanks
© 2024 Search & Filter Support. All Rights Reserved.
This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
We also use cookies to store items in your cart as well as allowing your to login on the site.
You can adjust all of your cookie settings by navigating the tabs on the left hand side.
By continuing to use this site, you also agree to our Privacy Policy.
Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.
*Other cookies used for logging in and cart functions will only be used when you use those features and cannot be disabled.
If you disable these cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.
This website uses Google Analytics to collect anonymous information such as the number of visitors to the site, and the most popular pages.
Keeping this cookie enabled helps us to improve our website.
Please enable Strictly Necessary Cookies first so that we can save your preferences!
More information about our Cookie Policy