Skip Navigation

[Resolved] Count posts (and taxonomies) connected through a relationship post

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)

This topic contains 3 replies, has 2 voices.

Last updated by Waqar 8 months, 1 week ago.

Assisted by: Waqar.

Author
Posts
#2616441

On this site hidden link we have the post type 'publications' which is connected by relationships to both 'contributors' (authors of the publication) and 'content partners' (the organisation responsible for the publication).

On this page hidden link views display the number of publications and features produced by this content partner.

I would also like to display the total number of contributors working for this content partner, but the posts are not directly connected - both are connected only to the publication. Is there a way to do this with Views?

And then related to this, I'd like to display the taxonomies of the publications connected to the this content partner - see here hidden link - this is in the old version of this site that we are migrating from Wagtail to WordPress and I need to achieve the same thing. Is this possible with Views? I need to display all the relevant subjects, and also a total count, but not show duplicates - i.e. consolidate the results across all the publications.

#2616885

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

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

You can use the nested views to show the count of related posts and the taxonomies. And since the nesting of views is only supported in the classic/legacy views, you'll be using the classic/legacy editor views for this and not the blocks-based views.

For example, on the partners page, you'll use a parent view, to first show the related publications posts.
( ref: https://toolset.com/documentation/legacy-features/views-plugin/displaying-related-child-posts/ )

And inside the loop of this parent view, you'll include another view that will show the contributors, related to the current publication loop item.

Alternatively, if you're comfortable with PHP code customizations, you can also use the Toolset Relationship API, to programmatically get the related posts:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts

Note: For more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

I hope this helps and please let me know if you have any follow-up questions.

regards,
Waqar

#2617321

Thanks Waqar - I can get nested views to show a list of contributors fairly easily, but the issue is that some of the contributors are duplicated - i.e. the same contributor may have written many publications, and I don't want them duplicated. And then I don't actually want to show the names of the contributors, just a cumulative total (excluding duplications of the same name (linked contributor post).

#2617547

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for writing back.

If you decide to use the nested views for this, you'll need some custom script to remove the duplicates and then count the cumulative total of the remaining items.

For someone proficient with PHP, it would be straightforward and neater to get this count using the 'toolset_get_related_posts' function.

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