Try buildin function get_users. The code should be like that:
$args = array(
'role' => 'editor'
);
$editors = get_users($args);
foreach ($editors as $user) {
echo '<li>' . $user->ID . '</li>';
}
Related Posts:
- Display posts from multiple user roles
- current-user_can not working in loop
- Get Sticky User in user loop based on user role
- Get date of last update outside of loop
- How do I get the attributes of a short code from a post?
- WordPress category & taxonomy loop with pagination
- Changing behavior of the loop twice in one page
- Show scheduled posts in archive page
- post__in – Placing content from a foreach loop inside of an array
- loop query exclude meta_key with meta_value
- “Blog pages show at most” in The Loop
- wp_insert_posts Fatal error: Maximum function nesting level of ‘100’ reached, aborting!
- Post Loop not Returning Permalink
- Displaying child page content of a certain parent
- Pagination adding extra posts only on page 2
- If Loop has odd number of posts on last page Custom style for last post in it
- Custom page template
- Get posts that matches specific terms of multiple custom taxonomies
- add_filter() doesn’t work in loop
- The Loop in Static Page
- Content/Excerpt length control for a specific loop?
- Two loops by pre_get_post on same page
- Why we use if with while loop?
- Loop posts only excluding first post
- Loop repeating design pattern
- Sort Posts By Category?
- Can’t access login screen, wp-login.php 404’s
- Customize WooCommerce Product Images (Placement and size) [closed]
- Create a loop that gets pages with their template
- Why is my loop not dynamically grabbing the correct Category and displaying all categorized posts?
- get latest 5 posts and a specific post and sort in a specific order
- How to check if a post exist?
- Query posts if meta key starts with
- 3 Posts in Loop, Show Stickies First
- Loop within a loop (Again) for template
- How to use current_post to open a new unordered list every five posts
- Why cant you place the Loop outside of the index.php?
- sticky post in custom loop
- Rating system and changing the loop
- Pagination for multiple loops
- Ajax Button to load more Posts into a timeline
- How to target thumbnails of the first post in the loop
- On single.php, fetch 2 posts created after and 2 posts created before in relation to the actual post (using menu_order)
- Problem getting current post tags to show in a widget
- Does WordPress Loop have a function like Shopify’s cycle?
- Combine the results of two loops [closed]
- How to show more random posts if Tag has less than 3 posts
- How to display pending posts on the homepage only for editors
- How can I improve the performance of this query_posts loop?
- Add leading zero to current post display [closed]
- Output meta into arrays
- Is there any good reason for two CSS files to @import each other?
- Adding div after every two post on main loop! Why will first post not get counted?
- Moving wordpress to different url/server creates redirect loop
- Pulling in featured image into default recent posts widget
- Random post link generator messes up the loop
- Modify loop output for a specific list of categories
- how can i order the category by date
- Print the whole page?
- excerpt not showing up
- Pagination for two loops
- Announces with different formatting dependently on a number
- Loop info in jquery Tabs – loop into a variable?
- Thumbnail Image Rounded Corners w CSS (or any other good method)
- Several loops in sidebar issues
- Adding $args to wp_schedule_event() causes hook to add infinitely to WP Cron
- $post is undefined in wordpress loop [ajax]
- Duplicated tag in loop
- Insert content above an embedded video inside Wordress’ php the_content
- Loop only shows first two posts
- Why is my archive page looping through all but one post?
- Use ACF Category Image for all Taxonomy Archive Views
- Loop with custom posts, to include information from different custom post type
- the loop printing post in one grid
- Check value of post meta within IF statement
- My WordPress installation doesn’t load correct template
- Work arounds for conditional checks inside the loop in search.php?
- adding tax_query to $query_string
- Popular posts with Varnish ESI
- Querying posts from only one category and exluding the latest post
- Remove posts_orderby filter then add it back in
- WP update_post_meta link loop
- How do I aproach this?(for sale, for lease, sold->move something from a category to another)
- How to fix pagination for custom loops?
- query_posts ignores the argument
- Need some help with “the_widget()” function
- Conditional Check in The Loop’s Parameters
- How does the JSON API work to parse incoming JSON and fetch a post based on an ID?
- show posts from one category with comments only
- Exclude Authors based off date of last post
- Loop from another WP site onto mine
- Having issue with WordPress loop
- How to implement template file and the loop
- I need to update the post query? [closed]
- Wrap every 2 divs in row – for each loop [closed]
- How to add class to the last image of the last post in a loop
- Multiple loop with pagination in same page
- Why did my most recent article fall behind an older one on my site?
- wp_mail function not working in user query loop
- How to set and retrieve cookies while in the loop