Query Users
This page covers how to query WordPress users.
Basic usage
Paste this directly into the query arguments editor in the Loop block's sidebar:
[
'number' => 10,
'orderby' => 'display_name',
'order' => 'ASC',
]
Common arguments
Arguments follow the WP_User_Query API — any argument it accepts works here too.
| Argument | Description | Example |
|---|---|---|
role | User role | 'author', 'editor' |
role__in | Multiple roles (OR) | ['editor', 'author'] |
role__not_in | Exclude roles | ['subscriber'] |
orderby | Sort field | 'display_name', 'registered' |
order | Sort direction | 'ASC', 'DESC' |
number | Limit results | 10 |
has_published_posts | Only users with posts | true, ['post'] |
include | Include specific IDs | [1, 2, 3] |
exclude | Exclude specific IDs | [1] |
search | Search by name/email | '*john*' |
More query examples
Team page
[
'role' => 'author',
'orderby' => 'display_name',
'order' => 'ASC',
]
Authors with post counts
[
'has_published_posts' => ['post'],
'orderby' => 'post_count',
'order' => 'DESC',
]
Contributors (multiple roles)
[
'role__in' => ['author', 'editor', 'contributor'],
'orderby' => 'display_name',
]
Staff by role
[
'role' => 'staff',
'orderby' => 'display_name',
'order' => 'ASC',
]
Template examples
In the HTML inspector, the Loop block uses get_users() syntax. Query arguments are managed by the sidebar — the inspector shows get_users() with empty parentheses to keep the template readable.
Staff directory with custom fields
{% for user in get_users() %}
<div class="staff-card">
<img src="{{ user.avatar(120) }}" alt="{{ user.name }}">
<h3>{{ user.name }}</h3>
<span class="department">{{ user.meta('department') }}</span>
<span class="phone">{{ user.meta('phone') }}</span>
<a href="mailto:{{ user.user_email }}">{{ user.user_email }}</a>
</div>
{% endfor %}
Simple author box (single post)
This doesn't need a loop — use the author provider directly on a single post template:
<div class="author-box">
<img src="{{ author.avatar(96) }}" alt="{{ author.name }}">
<h4>{{ author.name }}</h4>
<p>{{ author.description }}</p>
<a href="{{ author.link }}">All posts by {{ author.first_name }}</a>
</div>
Common mistake
get_users() without a role argument returns all users on the site, including subscribers. On a site with thousands of registered users (e.g., a membership site), this can be very slow. Always filter by role or use has_published_posts to limit results.
Next steps
- User provider — all fields available on user items
- get_posts() — query posts by a specific author
- Loop — loop concept and data sources