Skip Navigation

[Resuelto] limit View output to one post per author

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

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)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por nicholasM hace 6 años, 8 meses.

Asistido por: Christian Cox.

Autor
Mensajes
#623027

I have a views parametric search and when the results are displayed it should only be possible for each author to have one result show up for a give criteria as all fields of the search have been made required. So the only way there would be multiple for one author is if they entered the same categories more than once. Unfortunately this would be a way for people to make their results fill up the first page of results so I need to limit the output to one per author. hoping there is a way with conditional output to perform this filter?

#623065

Hi, unfortunately our conditional HTML feature isn't designed to help you hide results this way. If you want to limit the post results to only one per author, then it will require custom code. That falls outside the scope of support we provide here in the forums. A skilled developer might be able to offer a solution using our wpv_filter_query or wpv_filter_query_post_process APIs. We have documentation about those filters here:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query_post_process

We also have a portal available where you may connect with developers with Toolset knowledge here:
https://toolset.com/contractors/

#625036

Thanks, turned out because I always needed only one result in any query on the site I was able to just use a global groupby function however I will probably use the hook you provided to only attach it to that query for best practice.

function filter_authors($groupby) {
  global $wpdb;
  $groupby = " {$wpdb->posts}.post_author";
 return $groupby;
}
add_filter('posts_groupby','filter_authors');