Skip Navigation

[Resolved] Child Count with post relationshi-p

This support ticket is created 6 years, 2 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.

Our next available supporter will start replying to tickets in about 8.17 hours from now. Thank you for your understanding.

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 3 replies, has 2 voices.

Last updated by Shane 6 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#1107662

I'm trying to implement a similar solution to the one described here to count child posts.

https://toolset.com/forums/topic/counting-children/

+ I have a View that lists all parents (Artist)
+ I have another View that returns a single count of Artists in a relationship with artists_product. It accepts a post_id (artist).

It works when I call it manually with a post_id; however, when I use it in the Artist Loop Item, the browser spins then goes blank. Is my "Count" view hitting the database each time? There's about 750 Artists. Is there a better way to do this?

Thanks

#1107716

Shane
Supporter

Languages: English (English )

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

Hi Craig,

Thank you for contacting our support forum.

Is it that you want to call the view with a dynamic ID as a parameter instead of having to manually enter the ID ?

Please let me know.

Thanks,
Shane

#1107764

Hi Shane,

Yes. Call the top level parent listing View, and inside its loop, passing a shortcode representing the current post ID in the loop in order to get the child count of that particular parent.

If I call the View that returns [wpv-items-count] 750 times, probably not a good use of resources

Thanks,
Craig

#1107789

Shane
Supporter

Languages: English (English )

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

Hi Craig,

You can probably pass this into the view [wpv-post-id] Instead of manually setting the post ID