Skip Navigation

[Resolved] Always show markers of a custom post type and filter different custom post type

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a map that displays markers from a View that displays results from two different custom post types. I would like to be able to always display all results from custom post type A, but allow the User to apply front-end filters to filter custom post type B.

Solution:
This is possible using two separate Views, with some limitations.
- Since you already have one View set up with custom search filters, you should uncheck the Content Selection checkbox for the Monuments post type in this View. This View should only include Restaurant posts in the Content Selection.
- Create a separate View that shows all Monument posts. Insert map marker shortcodes in this View, but do not insert another map shortcode. Set the map_id attribute in these marker shortcodes to point to the same map_id from the original view.
- Insert the Monuments View in the same template or post as the original Restaurants View.
- I see a Distance filter at the top of the page. If you plan to filter both Monuments and Results using the same Distance filter, you must apply an identical Distance Query Filter in the Monuments View as well. You can hide the duplicate front-end distance filter in this View by commenting out the wpv-filter-meta-html shortcode in the Output Editor of the Monuments View.
- AJAX updates are not be fully supported when two separate Views are used on the same page. A submit button with page refresh is required to load both sets of results on the same map.

Relevant Documentation:
https://toolset.com/course-lesson/displaying-a-list-of-posts-on-a-map/
https://toolset.com/course-lesson/filtering-and-ordering-map-markers-by-distance/
https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/

This support ticket is created 3 years, 5 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.

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 4 replies, has 2 voices.

Last updated by David Gimenez 3 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#1852011

Hi there.

I have a view with a custom search and 2 custom post types, by example restaurants and monuments . I want that custom search filters restaurants but not filter monuments. The monuments will be visible always, and staurantser are filtered by custom search.

I'm thinking and testing without result.

Is this possible?

Thanks in advanced

#1852583

Hi, it depends on how you are building the Views and how you want to display search results. Can you provide more information?
- Are you using the Block Editor or the legacy Views editor to build this search and display system?
- Do you want both Restaurants and Monuments to appear in the map as markers?
- Do you want both Restaurants and Monuments to appear in the search results together?
- How do you plan to sort the search results outside the map?
- Which custom search filters will be provided in the front-end search?

#1852633

Hello Christian, this is David.

I'm using legacy views editor.

U can see the frontend filters here: hidden link

If you click in the cluster with number 23 you'll se some building markers and one H marker. If i filter the results the H dissappear because it's not a restaurant. I'd like that markers with H (monuments) remain in the map always. I only want filter restaurants not monuments, but if I filter restaurants the monuments must be in the map.

Filters of restaurant (for now) are:
Restaurants Custom fields
2 Restaurant Taxonomies

Is this possible?

Thanks for your time and help Christian

#1852673

Yes, this is possible using two separate Views, with some limitations.
- Since you already have one View set up with custom search filters, you should uncheck the Content Selection checkbox for the Monuments post type in this View. This View should only include Restaurant posts in the Content Selection.
- Create a separate View that shows all Monument posts. Insert map marker shortcodes in this View, but do not insert another map shortcode. Set the map_id attribute in these marker shortcodes to point to the same map_id from the original view.
- Insert the Monuments View in the same template or post as the original Restaurants View.
- I see a Distance filter at the top of the page. If you plan to filter both Monuments and Results using the same Distance filter, you must apply an identical Distance Query Filter in the Monuments View as well. You can hide the duplicate front-end distance filter in this View by commenting out the wpv-filter-meta-html shortcode in the Output Editor of the Monuments View.
- AJAX updates are not be fully supported when two separate Views are used on the same page. A submit button with page refresh is required to load both sets of results on the same map.

#1857983

My issue is resolved now. Thank you for your tiem and help!

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