Skip Navigation

[Gelöst] Display child post count on parent

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:

I want to display the total child post count on the parent page.

I have a custom post type named 'Activities' and I have one more custom post type named 'Reviews'
The Reviews post type is a child of Activities.

I want to display the child post count on each parent page.

For example:

Parent: https://URL/activity/sailing-at-gateway-of-india-mumbai-seabird-sailboat/

Child 1: https://URL/review/8716/
Child 2: https://URL/review/8713/
Child 3: https://URL/review/8683/

The parent has 3 child posts.

On the parent page, I want to display the count i.e. 3.

Solution:

You can create a view to list child "review" posts:
https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/

And display only the shortcode [wpv-found-count]:
https://toolset.com/documentation/user-guides/views-shortcodes/

Then put above view into the single parent "Activities" post for displaying the child post count

Relevant Documentation:

https://toolset.com/documentation/user-guides/views-shortcodes/

This support ticket is created vor 6 Jahren, 10 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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/Hong_Kong (GMT+08:00)

Dieses Thema enthält 5 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Luo Yang vor 6 Jahren, 10 Monaten.

Assistiert von: Luo Yang.

Author
Artikel
#610678

I want to display the total child post count on the parent page.

I have a custom post type named 'Activities' and I have one more custom post type named 'Reviews'
The Reviews post type is a child of Activities.

I want to display the child post count on each parent page.

For example:

Parent: versteckter Link

Child 1: versteckter Link
Child 2: versteckter Link
Child 3: versteckter Link

The parent has 3 child posts.

On the parent page, I want to display the count i.e. 3.

Kindly help.

#610932

Dear Prasad,

You can create a view to list child "review" posts:
https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/

And display only the shortcode [wpv-found-count]:
https://toolset.com/documentation/user-guides/views-shortcodes/

Then put above view into the single parent "Activities" post for displaying the child post count

#611231

Hi Luo,

I followed the steps you gave.

After I add the view on the parent page layout, the count is displayed thrice. Please check the link: versteckter Link

I want the count to be displayed only once.

Kindly help.

#611262

You just need to put the shortcode [wpv-found-count] outsider the <wpv-loop>, for example:

[wpv-layout-start]
	[wpv-items-found][wpv-found-count]<!-- Put it here -->
	<!-- wpv-loop-start -->
		<wpv-loop>
		</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

Then it will be able to display only once.

#611468

Hi Luo,

Thank you very much for the help.

The solution you gave me worked perfectly fine.

#611610

You are welcome