Forums › Forums › Search & Filter Pro › Query Custom Post by ACF Dropdown Value
- This topic has 18 replies, 2 voices, and was last updated 9 years, 3 months ago by
Trevor.
-
Anonymous(Private) December 15, 2016 at 6:43 pm #76869
I’m stuck and I’m not sure if the plugin will allow this. I have custom post types which include Advanced Custom Field dropdowns to select a US State and counties within each state. On the front end, the custom posts will show info that has not been assigned a state or county (i.e. at the national level). I want to include two dropdown lists so that a visitor can add to the custom post content by just the state or also by county, depending on the state selected. I want to use AJAX so the page does not refresh.
Anonymous(Private) December 16, 2016 at 3:39 pm #77068No. A visitor to the site should be able to click one dropdown to pick a state. Posts tagged by that state with an advanced custom field dropdown should then display on the screen. The visitor should also be able to click a second dropdown to select a county from that state in order to display more posts specific to that county.
Anonymous(Private) December 18, 2016 at 8:20 am #77331I had those settings. I thought it wasn’t working because the dropdown was displaying as this little sliver of a box, but I realized CSS was the answer for that.
The problem I have though, is that the results show all posts by default. Is it possible to display relevant results only if the corresponding dropdown option is selected? Or in other terms, can I disable the default selection, All Items, so that all items do not display by default?
Anonymous(Private) December 19, 2016 at 5:38 am #77477I’m struggling to figure out how to do that. Maybe I’m missing it, but I cannot find documentation on using conditions. I am using the shortcode display method. Would you please explain how to show alternative content when the filter has not been used?
I have my theme displaying what I want by default, so that’s not a problem. I just don’t want the filter to generate any content unless an option has been selected.
Sorry to keep bothering you!
Trevor(Private) December 19, 2016 at 8:38 am #77495Sure. In the code snippet in the linked example post, the form ID number is included (255). You need to change that for the ID number of your form (for example you can see the ID number in the shortcode). See this post.
Where it says
echo '<div>Nothing to see here folks!</div>';is where you put whatever you need to show the posts that you want. I do not know how to do that. There may be a function in your theme that you can call. Most likely you need to look at your theme template files, or ask your theme author.Anonymous(Private) December 20, 2016 at 4:52 pm #77846Ok, I got that much to work the way I want. Thanks for the info. I thought when you said to add a condition that I was supposed to do so from the Post Meta tab within the plugin.
Now I’m struggling to figure out how to get the second dropdown to populate based on the selection of the first dropdown.
Trevor(Private) December 20, 2016 at 4:56 pm #77851If you have done what I said here, it should work:
https://support.searchandfilter.com/forums/topic/query-custom-post-by-acf-dropdown-value/#post-77270
-
AuthorPosts