Skip Navigation

[Resolved] Is there a way to get the view to only show the most recent in the same location as the property the view is shown in

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

Problem:

Use Views plugin to query posts, with a taxonomy filter, the only problem with this approach is an issue I thought I had solved a long time ago but apparently wishful thinking and that problem is that this solution is also not taking the hierarchy into consideration.

Solution:

Views plugin is using WordPress class WP_Query to query posts, by default, the taxonomy filter will include child terms for hierarchical taxonomies.

In your case, you can try with Views filter hook "wpv_filter_query" to change the parameter "include_children" to false, for example this thread:

https://toolset.com/forums/topic/display-posts-for-parent-taxonomy-without-children-2/#post-228939

Relevant Documentation:

https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

include_children (boolean) - Whether or not to include children for hierarchical taxonomies. Defaults to true

This support ticket is created 5 years, 9 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by johnh-18 5 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#1224824

Dear Luo,

Many thanks for your message and solution which works but is not ideal when the site grows and it does not take the location hierarchy into consideration. But there may be another way to do this so continue to read and let me know what you think.

1. Add the 'property locations' taxonomy to the 'Destinations' post type - see attachment A.

2. Use the 'properties-most recent view' in the that is related to the property locations taxonomy - scroll down to the bottom of this page - hidden link - and / or look at the Elementor 'property destinations page' template.

The only problem with this approach is an issue I thought I had solved a long time ago but apparently wishful thinking and that problem is that this solution is also not taking the hierarchy into consideration and you may want me to open a new ticket for this - please let me know if you do.

To explain, go to hidden link and scroll down to the bottom of the page (or see attachment B). As you will see, the 'most recent' selection of properties include not only properties in the same destination as property the view is shown in but all destinations in France such as the Alps.

Is there a way to get the view to only show the most recent in the same location as the property the view is shown in? If yes, the problem with 'most recent properties' should be solved for both the property page and the destinations page.

3 questions
- is it possible?
- is it a good solution?
- should I open a new ticket?

Best regards / john

#1224878

Dear Luo,
Thanks for opening a new ticket. Please let me know if you need any further info or if there is anything you want me to do.
Best regards/john

#1224884

Hello,

Thanks for the details, yes, it is possible.

Views plugin is using WordPress class WP_Query to query posts, by default, the taxonomy filter will include child terms for hierarchical taxonomies, see WordPress document:
https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters
include_children (boolean) - Whether or not to include children for hierarchical taxonomies. Defaults to true.

In your case, you can try with Views filter hook "wpv_filter_query" to change the parameter "include_children" to false, for example this thread:
https://toolset.com/forums/topic/display-posts-for-parent-taxonomy-without-children-2/#post-228939

For the question: is it a good solution?
That depends on yourself, in my opinion both solution are good for your case.
They both can setup relationships between post types "Destinations" and "Perperties"
- my solution uses Toolset post type relationship
- your solution uses intermediate taxonomy

#1225183

My issue is resolved now. Thank you!