Skip Navigation

[Resolved] CPT Relationships Taxonomy acessess

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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/Karachi (GMT+05:00)


I have created the many to many relationships. I want to display all the taxonomy (tags or category) of related post from other CPT.

For Eg. I have one CPT which is Organization, and second CPT is Announcements which has its own categories, the announcements are announced by org. now I want to display all the categories or tags in the front end under which each organization has made the announcements.



Thank you for contacting us and I'd be happy to assist.

To display the data like taxonomies from the related posts, you'll need to use the view with the relationship query filter.
( ref: )

Can you please share the link to the example page, where you'd like to show the related taxonomies? Also, do you have any example of the format in which you'd like to show these announcements?

I'll be in a better position to suggest the next steps, accordingly.



my website is in local development
but for eg on this link hidden link
grant type: is coming from below mentioned related grant opportunities announced by this agency on the same page i want them to dynamically be shown.


Waiting for the response


Thank you for sharing these details.

To show the list of related taxonomies, you'll need to register a custom shortcode. Assuming that the relationship slug on your website is 'organization-announcement' and the taxonomy slug is 'announcement-category', the code will look like this:

add_shortcode('get_related_taxonomy_items', 'get_related_taxonomy_items_func');
function get_related_taxonomy_items_func() {

	$current_post_id = do_shortcode('[wpv-post-id]');
	$relationship_slug = 'organization-announcement';
	$taxonomy_slug = 'announcement-category';
	$tax_links = array();

	$related_posts = toolset_get_related_posts($current_post_id,$relationship_slug,'parent',999999,0,array(),'post_id','child');

	foreach ($related_posts as $related_post ) {
		$terms = get_the_terms( $related_post, $taxonomy_slug );

		if ( $terms && ! is_wp_error( $terms ) ) {
			foreach ( $terms as $term ) {
				$term_link = get_term_link( $term );
				$tax_links[] = '<a href="'.$term_link.'">'.$term->name.'</a>';
	$tax_links_output = implode(', ', array_unique($tax_links));
	return $tax_links_output;

The above code snippet can be included through either Toolset's custom code feature ( ref: ) or through the active theme's "functions.php" file.

The shortcode will get the related announcement posts from the current organization post using the "toolset_get_related_posts" function ( ref: ) and then return their related taxonomies, making sure to remove any duplicates.

Next, to show the related taxonomy items on the single organization post, you can call this shortcode like this:


Important Note: The custom code examples from our forum are shared to get you started in the right direction. You're welcome to adjust them as needed and for more personalized customization assistance, you can consider hiring a professional from our list of recommended contractors:


I have tried this method but got no results it's not returning anything. Just want to crosscheck by "relationship slug" you mean the relationship which I have created for organization and announcement and 'announcement-category' is taxonomy for announcements I have done this way but on front end Its not showing any category, it displays blank.


Thanks for this update and your understanding about the slugs is correct.

To troubleshoot why this custom shortcode is not working, I'll need to see how the related elements are set up in the admin area.

Can you please put your website on an online server and share its admin access details?

Alternatively, you can share the clone/snapshot of your localhost website, so that I can deploy it on my test server.
( ref: )

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the website's access details.


Thank you for sharing the website's duplicator package.

During troubleshooting, I noticed that the order of posts in the relationship "Research Fundings & Organizations" was reversed from my test website, which changes the 'parent' and 'child' roles of the post types.
( the post type on the left is the parent and the one on the right is the child )

I changed the line, reversing the 'parent' and 'child' roles:

$related_posts = toolset_get_related_posts($current_post_id,$relationship_slug,'parent',999999,0,array(),'post_id','child');


$related_posts = toolset_get_related_posts($current_post_id,$relationship_slug,'child',999999,0,array(),'post_id','parent');

And made sure that the custom code snippet was set as active ( screenshot: hidden link ) and it started working on the single "Funding Organizations" posts.
( screenshot: hidden link )


My issue is resolved now. Thank you for the awesome support

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