If I’m understanding this correctly something along these lines should work.
$authors = array( 1, 2, 3 ); // privileged users array
$signed_in_user = wp_get_current_user(); // get current user
// check if singed in user is in authors array
if ( in_array( $signed_in_user->ID, $authors ) ) {
$query = array(
'posts_per_page' = -1,
'author__in' = $authors
);
}
else {
// alternate query for other users
}
$posts = new WP_Query( $query );
Related Posts:
- author.php with ACF and CPTs
- Query to return maximum of one post per author
- 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
- Meta query with string starting like pattern
- WP Query where title begins with a specific letter
- WP Query orderby meta key natural sort?
- querying with custom meta field with meta_query
- Order by two meta keys
- multiple meta key but get server load is very high
- Merge 2 args in one WP_Query and order it by date
- How to bring specific post to front of wordpress loop?
- How can i get the last post from wp multisite?
- Use meta_query to display events by date in custom field
- Sticky Post default functionality with WP_Query is ignored when using AJAX
- tax_query OR with empty result returns all posts
- Using one WP_Query object within the loop of another WP_Query object
- Order by slug in get_terms with multiple taxonomies
- Is there any advantage of using default WordPress Search instead of creating a custom one?
- How to access WP database inside ipn.php? [duplicate]
- posts_per_page not working for first page of pagination
- Advanced ordering of query_posts
- Add class to first post in custom loop using post_class filter
- echo a specific meta_key queried through a custom post
- How to show more post at a given category?
- WP_Query returns posts_per_page + 1 every time
- Merge two search functions for custom post type
- WP_Query – Accessing MetaValue from Query Result
- problems with comments_number()
- Trying to retrieve random post, getting a page
- Does WordPress have something like Drupal’s DB API?
- PHP – Loop custom post type categories within jQuery Tabs
- How order posts from category by date and comment count?
- Get a list of ACF Repeater-Fields as array
- query_vars empty when using custom url with custom rewrite rule
- Get query results with a page title
- Show single posts date, in a page of posts
- Post archive for certain post format
- Compare “Main” post ID to ID inside wp_query loop
- Attempt to display site authors in a carousel – User Image not Outputting inside li tags
- Add AJAX “Load more” on custom query block
- problem with the loop
- Order WP_Query by meta_key priority when ‘OR’ relation used for multiple meta values
- Why my query is not “Main_query”?
- Filter sub-category from checkbox form
- Facing problem with tax_query results
- How to add a “base” filter for all posts visible to visitors on the site?
- sanitize_post() is not sanitizing Post Object
- wp query search multi terms
- How to get top rated posts using wp query?
- Unusual high query of user meta data
- Woocommerce featured products query no longer working
- add action for wordpress query at a specific position
- How do I get all authors posts of a custom post type outside loop
- How to query wordpress with array of meta_values?
- Updating an intensive wp_query result once daily
- Custom WP_query and integrating into theme file
- Get newest value of an array
- Filter custom post type by custom taxomony
- Why does order ASC break offset in WP_Query?
- new WP_query using custom fields
- Having Trouble Running Query From Shortcode Using Tribe’s Events Plugin
- Change ‘post_modify’ with a query
- An archive page without post format (just standard post)
- Query Posts to fetch Posts with Unique Tag
- Can’t figure out query logic
- Convert a WP Query into a simpler SQL query to fetch only COUNT of posts
- Duplicate posts showing up in loop using infinite scroll
- WP_Query orderby not working on custom post_type
- wp_query->set for several categories
- Getting posts via WP Query
- Print post data inside loop using theme content template
- Where to find WP_Query class?
- How to know which editor published a post programmatically?
- WP_query shortcode inside acf Repeater breaks the repeater loop