Skip Navigation

[Resuelto] Post appear in a View multiple times if in multiple categories

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

Problem: I have a View of posts filtered by taxonomy, and I want each post to appear multiple times depending on the number of terms that match the filters.

Solution:
The only way to show a post multiple times in a single View is to use the wpv_filter_query_post_process filter to manipulate the View's results after the filters are applied.

Or, use a View of posts nested inside a View of terms, and set up the filters as links that update the URL parameters correctly.

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query_post_process

This support ticket is created hace 6 años, 6 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Etiquetado: ,

Este tema contiene 1 respuesta, tiene 2 mensajes.

Última actualización por Christian Cox hace 6 años, 6 meses.

Asistido por: Christian Cox.

Autor
Mensajes
#902466

I have a page here:

enlace oculto

Click on 'Clinical' and then all of the sub-categories to make all posts appear. There are 6 but I want each post to appear multiple times if it is in multiple sub-categories.

I think this is independant of the isotope filter so doesnt need to factor that in, just that in the view I have created, a post will feature once for each category it is in.

Regards,

David

#902560

Hi, the only way to make a post appear multiple times in a single View's results is to apply some custom code that modifies the result set using wpv_filter_query_post_process:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query_post_process
In theory you could loop over the existing results and make clones as needed based on has_terms or something similar, then modify the pagination and post count values to match the final result set. When you factor in pagination, you can see how this becomes quite complex.

One alternative I can think of is to use two nested Views - one for the Supplier Categories and another for the Suppliers.
- View 1: A View of the Supplier Category taxonomy that is filtered by term, set by a URL parameter
- View 2: A View of Suppliers filtered by Supplier Category where the term is set by the parent taxonomy loop
- Insert View 2 inside the Loop of View 1.

Then you will have to recreate the filter buttons to work with View 1, so that the buttons work as links and update the URL appropriately, triggering an update of View 1. It will work best without AJAX updates, but you could probably make some JavaScript adjustments to work with AJAX.

You will also have to consider that the nested Loop structure will create nested markup, so you may have to do some DOM manipulation to get things to work in the Isotope system.