Skip to main content
added 89 characters in body
Source Link
Sally CJ
  • 39.9k
  • 2
  • 26
  • 48

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, who is not a meta key, and 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.

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, who is not a meta key, and you should use the exclude parameter:

$args = array(
    'exclude' => array( 10, 3, 4 ),
    'who'     => 'authors',
);
$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.

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.

Source Link
Sally CJ
  • 39.9k
  • 2
  • 26
  • 48

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, who is not a meta key, and you should use the exclude parameter:

$args = array(
    'exclude' => array( 10, 3, 4 ),
    'who'     => 'authors',
);
$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.