Overview

Use this tool to create custom code for WordPress User Query with WP_User_Query class.

Usage

  • Fill in the user-friendly form.
  • Click the “Update Code” button.
  • Copy the code to your project.
  • Or save it as a snippet and share with the community.

Examples

If you are still learning how to use this tool, check out the following examples:

The variable used in the code.
Show The Loop.
Show users associated with certain role.
Show users associated with custom role.
Show specific list of users to be included.
Commas separated list of ID's. e.g. 1, 2, 3
Show specific list of users to be excluded.
Commas separated list of ID's. e.g. 4, 5, 6
Show users associated with certain blog on the network.
Number of users to show.
Number of users to displace or pass over.
Ascending or Descending order.
Sort retrieved users by.
Display users with this custom field key. Display users with this custom field value.
Operator to test the custom field value. Custom field type.
Which users to query. Currently only "authors" is supported. Default is all users.
The total count of users found.
Set the fields you want to return.
Commas separated list of fields to return. e.g. id, user_login, user_nicename, user_email, user_url, user_registered

  Save Snippet
// WP_User_Query arguments
$args = array (
);

// The User Query
$user_query = new WP_User_Query( $args );