exclude specific authors from
WP_Query
You can do it like so:
$args = array(
'author__not_in' => array( 10, 3, 4 ),
);
$posts_query = new WP_Query( $args );
But if you meant “from WP_User_Query
“, then in WP_User_Query
, you should use the exclude
parameter, and that array('who' => 'authors')
shouldn’t be in meta_query
:
$args = array(
'exclude' => array( 10, 3, 4 ), // not author__not_in
'who' => 'authors', // not in meta_query
);
$users_query = new WP_User_Query( $args );
For the full list of parameters, refer to WP_User_Query::prepare_query()
for WP_User_Query
, or WP_Query::parse_query
for WP_Query
.
Related Posts:
- Function to check if author has posted within the last x days
- ajax category filter
- WordPress 4.9.5 PHP intermittent warning trim() expects parameter 1 to be string, array given
- author.php with ACF and CPTs
- Query to return maximum of one post per author
- Pagination custom query
- Order by two meta keys
- Finding all results from database within 500 miles of the given latitude and longitude [closed]
- Show only oldest post by author
- Shortcode returns escaped HTML tags
- Calling a custom excerpt function in a local loop
- How to get any tag ID
- Dynamically Override Fancy Title – Part II
- query posts in functions.php and update a field
- Show one post per author and limit query to 8 posts
- Get posts using WP_Query
- Finding post content that begins with a specific character
- Pagination 404 errors for author posts query on author.php
- Only display authors who have posts
- Best practice custom function, where to echo the variables?
- How to get user_id from wordpress database inside ajax function?
- Get List of all the Authors
- posts_per_page not working
- Exclude admin from WP_Query Contributors
- Multiple Loops Inside a Function
- How to delete taxonomy term when a wordpress user is removed?
- Exclude category for main query and custom
- Display posts from only one post form in custom query and exclude in main query
- 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)?
- Category applied to pages, creates multiple breadcrumb entries after a search query (On the translated site)
- Get authors by term id or slug
- How to filter, restrict and return posts based on custom user meta information
- WP Query using tax_query & meta_query
- Dynamic User Id
- wordpress search word, “hello world” ===> ‘hello+world’ ===> ‘hello’, ‘world’
- Custom Query by Author field and meta
- slow WP_Query for non-admin user
- Display most popular in the past two days
- WP_Query (list) posts according to author’s custom field
- meta_query not working as expected
- New WP_Query calls Pre_get_posts filter twice
- how to access query string in wordpress?
- Exclude some authors from query
- Get author if post has multiple authors
- All posts returned when author of 0 is queried
- Merge two search functions for custom post type
- Make a SQL query with wpdb in WordPress
- how to use pre_gets_posts to exclude one queried ID from homepage loop
- Error with function in functions.php?
- 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
- WP_Query author parameter not working
- Loading two different AJAX requests on two different pages
- Getting the post terms ‘wp_get_post_terms’ per post when within the functions.php file
- How to load a script code only in posts?
- Multiple meta_key ordering with pre_get_posts
- How do I fit WP_Query arguments into a function?
- Create a notification for post field
- query post by author gender
- Add URL Rewrite Rule To WordPress
- Trying to get property of non-object in: $wp_query
- WordPress dynamic AJAX query
- relation OR instead of AND – Filtered term ID’s in loop
- How can i show pagenavi in my author.php?
- how to show comments only author which send own posts in wordpress
- 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
- Pagination repeating posts on search results
- How to check if logged in user have pending custom post?
- Get authors list and sort them by recent posts
- Custom WordPress post query for displaying time-released content on website
- SEARCH QUERY PLEASE HELP | call_user_func_array() expects parameter 1 to be a valid callback php
- Custom query for custom post type not getting correct post ID
- Finding post ID dynamically on click
- how to move a page from one drop down menu to another drop down menu
- How to upload 3 attachments to current post?
- Global page ID variable empty error
- query all posts published by certain user id
- WP_Query & shortcode : Return 3 articles from a category WordPress
- Get post Number with local loop and template
- Save query in function for custom gallery
- Seach and categories not working when ignoring sticky posts in main loop
- Problem with custom WP_Query and underlying pagination/posts_per_page
- Calling a function with WP_Query only ever brings the first result
- What argument does my function need to echo get_results() query results
- Fetching $_POST from Page Template into functions.php
- Declare inline background image in functions.php
- I wan to process the following js to process the AJAX Request on my function to calculate author Total Post views
- Hiding all posts/products/pages from a site based on a custom taxonomy/domain name
- ordering and optimizing functions
- Why WP_Query in functions.php is not working when get_posts works?
- WP Query get posts by specific author IDs if one of several logged in authors
- Adding css tweak based on page template
- WP_Query and DES sort for Custom Taxonomy based upon a meta field?
- How to write a query-function as a query-shortcode?
- 1500+ duplicate queries via get_option function (query monitor)
- Variations as Single Products [closed]
- Excluding a category from frontpage but not from WP_Query