Hello, I created this site hidden link studying your site hidden link
I used Avada for the graphical layout and toolset for the CPT and CFields.
I followed the tutorials but I would like to see the correlates of the same city at the end of the page of the single property. How can I do?
Are the Cities created as a separate post type or are they taxonomies ? Essentially you want to display the properties that are in the same city as the one post being viewed.
Once I know if this is a taxonomy or another post type then I can properly advise you on how to achieve this.
The Cities created as a separate post type.
Can you please explain the difference if I create cities as taxonomies? I need to have some neighborhoods in a city as I can manage this division. Thank you
a.
There isn't an easy way to do this using Toolset Blocks through the interface. However with our views filter hook we can achieve this.
Add the following hook to your Toolset custom codes in Toolset->Settings->Custom Codes and activate it.
// Put the code of your snippet below this comment.
function tssupp_filter_by_current_post_parent( $query_args, $view_settings, $view_id ) {
if($view_id == 2383){
$parent_id = do_shortcode("[wpv-post-id item='@city-property.parent']");
$query_args['toolset_relationships'] = array(
array(
'role' => 'child',
'related_to' => $parent_id,
'relationship' => 'city-property'
)
);
}
return $query_args;
}
add_filter( 'wpv_filter_query', 'tssupp_filter_by_current_post_parent', 99, 3 );
What you need to do is replace everywhere you see 'city-property' with the slug of your relationship. To find the relationship slug go to Toolset -> Relationship and edit the relationship and you will see the relationship slug.
Secondly replace the 2383 with the correct ID of your view. Once you've done this your view should only display the posts that are related to the same city as the current property being viewed.
Please let me know if this helps or if you're having any issues at all.