Skip Navigation

[Resolved] Filtering custom post types backwards

This support ticket is created 5 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by garyC 5 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#1199482

Hi there, I am creating a site for a travel company, that has many destinations added as custom posts. There are 3 regions to these destinations; UK, Europe and Rest of the world, and within these there are specific countries/counties. I have created a CPT with 3 taxonomies, one for each region. Within these taxonomies, I have created a category for each country/county. Is this the best way to structure the content to allow me to filter them? When I create a View to filter by Taxonomy, I don't see any of the categories within.

The site will have 3 separate pages, one for each region. On each page, I need to create a dropdown filter, that will display every category within that taxonomy and then display the chosen posts in the template. Is this possible with the way I have structured the content or do I need to setup the structure differently? Also, the client wishes to hide all posts on the page by default, and only populate the page once a filter selection has been chosen. Is this also something that can be done?

So for example, I have a taxonomy of Europe, with categories within of Spain, France and Belgium. These 3 categories should display in the filter dropdown, and if I select Spain, reveal the list of Spanish posts in another region of the template.

#1199549

Hi, your approach seems okay. Here is some feedback.

When I create a View to filter by Taxonomy, I don't see any of the categories within.
Are you saying you don't see a front-end filter at all, or the filter doesn't contain any of the category terms you expect? Or you can't figure out how to create the filter in wp-admin? I'm not quite clear what you mean here. A screenshot will be helpful.

I need to create a dropdown filter, that will display every category within that taxonomy and then display the chosen posts in the template. Is this possible with the way I have structured the content or do I need to setup the structure differently?
Yes, it's possible given the structure you mentioned. In a View of these destination posts, you will use the Search and Pagination panel to add a front-end filter to filter by this taxonomy. Check out this guide that describes this process: https://toolset.com/documentation/user-guides/filtering-posts-by-user-selected-taxonomy/

Also, the client wishes to hide all posts on the page by default, and only populate the page once a filter selection has been chosen. Is this also something that can be done?
Yes in simple Views it's possible, but a bit of custom code is required and there are some limitations. The exact code depends on the filters that are present in the search View, and the URL parameters they produce. If you're comfortable writing code, you can check these examples:
https://toolset.com/forums/topic/troubleshoot-wpv_filter_query-in-functions-php/
https://toolset.com/forums/topic/displaying-posts-according-to-their-parent-posts/
And our API documentation here:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query_post_process
If you want more specific advice on this, feel free to create a separate ticket so we can discuss in more detail. Our support policy is one specific topic per ticket, to help keep things organized and searchable.

#1219504

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.