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.
Forums › Forums › Search & Filter Pro › Custom post type not showing in "post type" search form UI checkboxes
Hi,
I’m using the download monitor plugin to manage and display WP documents and would like to integrate the related custom post type (dlm_downloads) in a post-type based search form. Basically, the form should display items in the post types posts, events and downloads, along with filters for each one.
My problem is that Download Monitor’s “Downloads” post type shows up just fine under “Search in the following post types” but not under the post type filter.
Any idea of how this could be fixed?
Thanks
Hi again
If you take a look, we have a filter, which will allow you to modify any option in a field (so you will want to remove the first option):
https://searchandfilter.com/documentation/action-filter-reference/#filter-input-object
Take a look at the full featured example to get an idea how to move the options around.
Thanks
Hmm I’m a bit lost.
What I’m trying to do is not only to remove the all post types filter, but also ensure that one of the selected post types (in my case, press-releases) is selected by default instead in place of the removed filter. I’m not sure how I can use your example to achieve that. Any guidance would be much appreciated.
OK so this is as far as I got:
function filter_input_object($input_object, $sfid)
{
if(($input_object['name']!='_sf_post_type')||($input_object['type']!='radio'))
{
return $input_object;
}
foreach($input_object['options'] as $option)
{
if($option->value=="")
{
}
else if($option->value=="post")
{
}
}
return $input_object;
}
add_filter('sf_input_object_pre', 'filter_input_object', 10, 2);
All I need now is to assign actions for the ‘if’ and ‘elseif’. But I couldn’t find any example. I would like to hide or delete the option with no value and make the one with value ‘post’ preselected.
Can you help please?
Hi Thomas
Because we know the first option is the option we want to remove, we can do it a bit easier like this:
function filter_input_object($input_object, $sfid){
if(($input_object['name']!='_sf_post_type')||($input_object['type']!='radio'))
{
return $input_object;
}
if(isset($input_object['options'])){
//remove the first option from the array
$removed_option = array_shift($input_object['options']);
}
return $input_object;
}
add_filter('sf_input_object_pre', 'filter_input_object', 10, 2);
Now, I’m guessing that this will work (I didn’t test but it looks correct), however, I think next you want the results to be default fitlered by this option?
Thanks
The topic ‘Custom post type not showing in "post type" search form UI checkboxes’ is closed to new replies.
© 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