You need to GROUP BY
the author ID, which is going to require a filter on posts_groupby
. The Codex page for that filter is non-existent but it works like posts_join
. Something like…
function filter_authors($groupby) {
global $wpdb;
$groupby = " {$wpdb->posts}.post_author";
return $groupby;
}
add_filter('posts_groupby','filter_authors');
$args = array(
'showposts' => 3,
'author' => "1,2,3"
);
$the_query = new WP_Query( $args );
while ( $the_query->have_posts() ) : $the_query->the_post();
echo $post->post_title.' :: '.$post->post_author."<br/>";
endwhile;
Use your own values in $args
of course.
that will effect any other query on the page that runs after this block of code. You might want to remove the filter after you are done.
remove_filter('posts_groupby','filter_authors');
Related Posts:
- author.php with ACF and CPTs
- Show only oldest post by author
- Function to check if author has posted within the last x days
- Show one post per author and limit query to 8 posts
- Pagination 404 errors for author posts query on author.php
- Only display authors who have posts
- Get List of all the Authors
- How can I display list of all posts from a specific author, with publish dates in the future, on an author archive page (author.php)?
- Get authors by term id or slug
- Dynamic User Id
- Custom Query by Author field and meta
- slow WP_Query for non-admin user
- WP_Query (list) posts according to author’s custom field
- Exclude some authors from query
- Get author if post has multiple authors
- All posts returned when author of 0 is queried
- Posts in loop all show the same author when there are many authors
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- Display if author page is author page of current user
- Exclude authors IDs from WP_Query
- WP_Query author parameter not working
- query post by author gender
- How can i show pagenavi in my author.php?
- wp query to use both author id and meta_query
- Counting instances of words in the results of a post query
- Query posts by post type, author and post meta
- Get authors list and sort them by recent posts
- query all posts published by certain user id
- WP Query get posts by specific author IDs if one of several logged in authors
- How to get an array of post data from wp_query result?
- How to only display posts whose meta_value field is not empty?
- How to print the excuted sql right after its execution
- How to add taxonomy filter on the query fly?
- Pagination returns 404 after page 20
- Make a WP Query search match exactly the search term
- post_type is ignored by WP_Query when ‘tag’ argument is included
- How to query posts of standard post format. For real
- Orderby menu_order doesn’t work
- WP_Query by Category Name
- A WP_Query that will look for posts after 2 weeks ago OR with a certain meta value
- Ignore a filter on the media library
- if wp_query taxonomy term have posts
- Pagination broken when merging search results with additional WP_Query
- Select posts wich has no relationship in custom taxonomy
- How to display posts from multiple post type in random order in wordpress?
- Multiple keyword search
- WP-PageNavi gives me a 404 when using WP Query
- WP_Query, custom sort and custom filter
- How to wp_query posts with ajax
- Calling WP_Query with the same args in two different places produces two different results
- Custom Query – show first post twice?
- Next/Prev posts on same page
- What is considered a default query for the request filter?
- Two different conditions with a single WP_Query
- Creating query to show which editor (classic or block) was last used to edit a post/page
- Tax query clause inside a meta query clause?
- is_tax() function not working as expected
- Getting the current post number / make posts increment
- Optional Meta Query
- Set conditional on template based on referring page slug
- Multiple If Else with WP Query in WordPress
- Serve specific “template” page at any URL that ends in its slug
- WordPress pagination not working using WP_Query
- Meta_query on same meta key, with diffrenct values
- Can we return all category (not post) with Custom Query Filter? [closed]
- WP_Query – Exclude Posts
- Get latest post revision with wp-query
- date_query seems to be ignored by wp_query
- Filter Custom Taxonomy Posts
- Config.php issue in WordPress
- Is it possible to query from external database? [duplicate]
- WP_Query freezing
- WP_Query to output chosen term and posts with no term assigned
- Need to add onclick javascript at backend of my wordpress site
- How do you determine if a result in a search query is a post or a page?
- WP_Query by keyword OR post tag
- Display recent posts on another site
- WP_Query for products always returns empty
- Issue with data array format
- Meta Box WP_Query array for showing items with a certain relationship
- Multi-layered WP_Query
- `offset` WP_Query argument dont work via `pre_get_posts`
- Function the_posts_pagination() not compatible with WP_Query arguments
- Pagination of custom page with custom fields query
- WP_Query() not filtering posts for category
- WP_User_Query Orderby Not Working
- WordPress post_status and meta_query
- Custom query: post__in parameter causes query to be empty
- Custom query return
- WP_Query: Meta_Query with serialized value (or a workaround)
- Query All Attachments and Order by Parent Publish Date
- WP_Query using meta_query with LIKE doesn’t return what it should
- Query post Pagination Problem
- How to organize a WP_Query’s list of posts by category and display category title?
- Pull Instagram images into an existing loop?
- Query_vars not working for me
- Filtering product search results using tags
- How to include custom fields in wordpress search
- Extend search query to search meta keys values based on search string
- AJAX multiple search boxes not merging with array merge