Saltar navegación

[Resuelto] How to display the number of related posts

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:
When displaying posts from one side of a relationship (either individually, or listed by a View) how is it possible to display the number of related posts of some type?

Solution:
Create a View that queries the related post type and include a relationship Query Filter to limit the results to posts connected to the current post.

In the output section just after the wpv-items-found shortcode but before the wpv-loop tags output the count using the wpv-found-count shortcode. Don't include any other output (e.g. within the loop), and you would probably want to check the option to disable the wrapper div, depending on the context.

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-found-count

This support ticket is created hace 5 años, 8 meses. 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Etiquetado: 

Este tema contiene 4 respuestas, tiene 2 mensajes.

Última actualización por ThorstenS967 hace 5 años, 8 meses.

Asistido por: Nigel.

Autor
Mensajes
#1240283
NumberOf Occurencies.jpg

Hi Nigel,
as you wished, I created a new thread.
Is it possible (like in the uploaded image) to show the number (count) of "Themen" (topics) which belongs to each article? There is an themen-article relationship. I tried this in the "Themen View" with [wpv-found-count] but it always displays the same number (12). I know, there is no query filter, but if I use a query filter it doesn't show the "Themen" (Topics).

Thanks
Thorsten

#1240335

Nigel
Supporter

Idiomas: Inglés (English ) Español (Español )

Zona horaria: Europe/London (GMT+00:00)

To do this with Views, you have the View which lists Theme posts.

In the output section you need a nested View to query the article posts connected to the current Theme (i.e. a View to display articles with a Query Filter to show articles related to the current post in the loop), and in the output section of that View you would use the wpv-found-count shortcode to display the number of connections.

You would likely want to disable the wrapper div for that nested View.

#1240364
Number of Articles for Thema.jpg

I got it almost working, but the number will be displayed (because of the loop) as much as the "Thema" has articles (please see attached screenshot). I created a child view "Themen-Article Count Child View". How can I output it in the Themen View (where this Themen-Article Count Child View is nested) the count only once?

#1240370

Nigel
Supporter

Idiomas: Inglés (English ) Español (Español )

Zona horaria: Europe/London (GMT+00:00)

You need to place the wpv-found-count shortcode inside the wpv-items-found shortcode but outside the wpv-loop tags, so that it is output only once and not for every article iteration.

#1240411

My issue is resolved now. Thank you!