Skip Navigation

[Resolved] related CPT posts

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

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 4 replies, has 2 voices.

Last updated by andreaD-4 3 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#1973627

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?

#1973811

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Andrea,

Thank you for getting in touch.

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.

Thanks,
Shane

#1973903

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.

#1974011

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Andrea,

Thank you for your patience.

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.

Thanks,
Shane

#1975683

My issue is resolved now. Thank you!