Tell us what you are trying to do?
-----
I am trying to create a view with a filter and map. And I would like to filter children posts by parent posts' taxonomies and display results as a grid and markers on the map.
I was using your documentation but faced with issues.
-----
I have a situation similar to the following:
- let's say we have stores (parent post) and employees (child post).
- stores organized by the company in some structure: Regions -> Districts (first taxonomy)
- and stores have different locations: Provinces -> Cities (second taxonomy)
- employees may work in more than one store.
-----
I am trying to create a view, which would have:
- view employees
- map with stores
- filter by stores taxonomies, where, for example, I could choose some province and:
- - get all the stores on the map
- - all employees in a view, who work in the stores in a chosen province
-----
What I did:
- I created a view of stores with a filter by stores taxonomy
- Created a view of employees, where:
- - items in a loop, including marker look like this:
[wpv-post-body view_template="loop-item-in-employess-page-view"]
[wpv-map-marker map_id="map-6" marker_id="marker-[wpv-post-id]" marker_field="wpcf-store-address" marker_icon="" current_visitor_location="true" map_render="wait"] pop-up content [/wpv-map-marker]
- - query filter: "Select posts in a Stores-Employees relationship that area related to the current post in the loop."
- I nested Employees view in the Stores view
-----
I got the following issues:
- only two markers were displayed on the map (supposed to be more)
- when I applied taxonomy filter it did work properly only for stores, which markers were displayed.
- employees in the who work in two or more store are doubled.
- view created (looks like) in some way by stores but not in employees order. For example, if a store has one employee, the view ( 3 columns grid) would show only one employee per row. If 2 employees work at a store: 2 employees per row.
Is there any documentation that you are following?
yes:
https://toolset.com/forums/topic/filtering-custom-search-in-child-cpt-by-parent-wp-post-taxonomy/
https://toolset.com/2018/02/toolset-maps-features-in-reference-sites-viewing-geolocation-and-filtering-by-distance-in-action/
https://toolset.com/documentation/user-guides/display-on-google-maps/displaying-markers-on-google-maps/
Is there a similar example that we can see?
I don't have examples, sorry
What is the link to your site?
hidden link
Hello,
There isn't such a built-in feature within Views plugin.
If you are using Views to query "employees" posts, you can only filter the view by custom fields/taxonomies of "employees" posts, you can not filter the result by fields/taxonomies of other post type("stores"), this is a limitation of WordPress class WP_Query.
In your case, I suggest you try with a nested view:
1) Parent view, query "stores" posts, setup the custom search form with taxonomies filters:
- Regions
- Provinces
in the view's loop, display below child view
2) Child view, query the "employees" posts, filter by the post type relationship
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items
display the "employees" post information + parent "stores" post address field:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-one-related-item-parent
Hi Luo.
Thank you for your reply.
I did use nested views as described in a previous message: in the loops view of "Stores", I input "Employees" view.
It doesn't work properly and how I would need.
Please find more details on what I did in the previous my message and issues I got and need a help with. Let me know please, if I could add more info in order to help me resolve issues.
Q1) only two markers were displayed on the map (supposed to be more)
Please check my above answer, you need to display the map marker in the child "employees" view
Q2) when I applied taxonomy filter it did work properly only for stores, which markers were displayed.
As I mentioned above, this is a limitation of WordPress, those taxonomies are registered to post type "stores", so it will work only on post type "stores"
Q3) employees in the who work in two or more store are doubled.
Yes, it is expected result, but as a workaround, in the google map shortcode, you can display the marker text as: store title + employee name
Then each marker is unique in the google map
Q4) view created (looks like) in some way by stores but not in employees order.
Same as above, it is expected result in nested Views:
The result is order by the parent store view first, then order by the child employee view.
Thank you, Luo.
Basically, nested views is not a proper solution in this case as I understand.
Therefore I did the following:
- I assigned a parent post type (stores) taxonomies to children post type (employees) as well.
- I created a new view with employees loop, map and taxonomies filters.
I result I do not have duplicates, filters work properly, BUT
I still get an issue when not all markers are displayed on the map. I checked links you have provided and still can't find out why not all markers are shown on the map. I need your help with this issue
Here is an example of how my code a Loop Editor looks like
----------------------------
<div>
[wpv-map-render map_id="map-1" cluster="on" map_height="360px" style_json="link"]<h4>Please wait while map is loading</h4>[/wpv-map-render]
</div>
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<div class="wpv-loop js-wpv-loop">
<wpv-loop wrap="3" pad="true">
[wpv-item index=1]
<div class="row">
<div class="col-sm-4">
[wpv-post-body view_template="loop-item-in-employees-page-view"]
</div>
[wpv-item index=2]
<div class="col-sm-4">
[wpv-post-body view_template="loop-item-in-employees-page-view"]
</div>
[wpv-item index=3]
<div class="col-sm-4">
[wpv-post-body view_template="loop-item-in-employees-page-view"]
</div>
</div>
<div>
[wpv-item index=pad]
<div class="col-sm-4"></div>
[wpv-item index=pad-last]
<div class="col-sm-4"></div>
</div>
</wpv-loop>
</div>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-pager-nav-links output="bootstrap" links_type="dots"]
[wpv-no-items-found]
[wpml-string context="wpv-views"]No items found[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]
Here is an example of how my code in a Template for Employees View Editor looks like
----------------------------
[wpv-post-featured-image size="full"]
<br>
<div>
<h3>[wpv-post-link]</h3>
<p>
<i class="fa fa-home" aria-hidden="true"> [wpv-post-taxonomy type="region" item="@store-employee.parent"] <br>
</p>
</div>
[wpv-map-marker map_id='map-1' marker_id='marker-[wpv-post-id]' marker_title='[wpv-post-title]' marker_field='wpcf-store-address']
<div>
[wpv-post-featured-image size="custom" width="70px" item="@store-employee.parent"]
<div>
<div>
<h4>[wpv-post-link item="@store-employee.parent"]</h4>
</div>
<p>
<i class="fa fa-map-marker" aria-hidden="true"> [wpv-post-taxonomy type="store-location" item="@store-employee.parent"]
</p>
</div>
</div>
[/wpv-map-marker]
For the issue: not all markers are displayed on the map.
Please check these:
1) In case it is a compatibility problem, please deactivate other plugins, and switch to wordpress default theme 2017, and test again
3) If the problem still persists, please provide database dump file(ZIP file) of your website, also point out the problem page URL and view URL, which google marker should be display in the map?
I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/
I have tried the your database dump file, there are some tables missing, in order to debug this problem, I need the whole wordpress database, it should be able to include all wordprss tables + Toolset tables.
Please provide a downloadable URL for the whole wordpress database, and update it in your own private message:
https://toolset.com/forums/topic/filter-children-posts-thru-parents-taxonomies-and-displaying-markers-on-the-map/#post-1112383
Luo, thank you!
For now, we are not going to use the map search, therefore we don't have a need for a resolution of markers display issue.