[Resolved] Limit View output to one post per author before search / filtering is applied
This support ticket is created 3 years, 7 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I am trying to set a cpt view to display only one post from each author before any search / filtering is applied.
There is a function that seems to apply such feature, but runs everywhere. I would like to run something similar only for one particular view, but I can't get the if statement to work properly, nor to change add_filter to something to return $content with wpv_filter_query...
Here is the basic start:
function filter_authors($groupby) {
global $wpdb;
$groupby = " {$wpdb->posts}.post_author";
return $groupby;
}
add_filter('posts_groupby', 'filter_authors');
Thank you!!! I am also trying to remove the grouping (by author) after filtering is initiated for the cpt but I don't manage to get it working. When I hit the text search, the grouping stops, but it does not happen when I filter by custom post type (e.g. price range). The view is set with individual settings: Update the Views results without reloading the page / Update URLs after loading search results (if relevant).