WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to use query_posts() to show only posts from editors and administrators on my home page so that normal authors can post on their own pages, but not affect the home page.

Edit :

Thanks for the quick reply, I'm a bit of a novice when it comes to php, do you think you could give me the code I require? I'm currently using this, but getting no posts returned despite having several posts by an administrator:

$wp_user_search = new WP_User_Query( array( 'role' => 'administrator' ) );
$admins = $wp_user_search->get_results();
$args = implode(',', $admins);
share|improve this question
This is exact opposite of this question Hide posts from users with a specific role check out my answer there and if it fits I will probably close this as duplicate. – Rarst Jul 13 '11 at 18:56
@Rarst: the answer to this question is exactly the same minus the minus sign ( - ) in the query parameters but i guess its still something a lot of people would look for and not the other way around. – Bainternet Jul 13 '11 at 19:14

Code you are after:

$wp_user_search = new WP_User_Query( array( 'role' => 'administrator' ) );
$admins = $wp_user_search->get_results();
$admin_ids = array();
foreach($admins as $admin) {
    $admin_ids[] = $admin->ID;
$args = implode(',', $admin_ids);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.