Skip Navigation

[Resolved] limit View output to one post per author

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

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)

This topic contains 2 replies, has 2 voices.

Last updated by nicholasM 6 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#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');