Unless you want to retrieve custom data from the database, you will hardly ever need to make use of the WPDB
class (or its global object, respectively). Though it is obviously possible to do things that way as well.
Just for the sake of completeness, if you had a reason to not use a more abstract function, you’d have to employ JOIN
in the select syntax as user roles live in the usermeta table.
But it’d be much simpler to make use of the get_users
function:
$args = array(
'role' => 'author',
'orderby' => 'display_name'
);
$authors = get_users( $args );
[EDIT] As for the question in the comments (ordering by the number of posts):
Use 'post_count'
as an argument for the 'orderby'
parameter (and read the linked codex page, which gives you all the possible arguments).
Related Posts:
- In what part of the WordPress core does the users table and usermeta table get joined?
- Modify Database in Multi-Site wp_usermeta table
- Best practice to import user base (subscribers) from one website to another?
- How to delete a particular row in a database table
- Select From wpdb – Author/User Directory page
- How to get specific table by current user login
- Multiple developers / editors working on a site in progress
- How many users can WordPress handle?
- Get error messages when $wpdb->insert() returns false?
- Detecting errors generated by $wpdb->get_results()
- Does dbDelta delete columns as well?
- wpdb update add current timestamp not working
- WordPress Unit Testing – Cannot Create Tables
- How to track user progress?
- Why does $wpdb return strings for mysql integer values?
- $wpdb->prepare() warning in WordPress 3.5
- Inserting data into custom tables
- Performance tips for a large user base [closed]
- How might I retrieve a featured post image from an external WP site and display it as a link back?
- Export wordpress table to excel
- Inserting Post Meta From SQL
- Why does dbDelta() not catch MysqlErrors?
- What causes the “max_user_connections” warning on WordPress frontend?
- $wpdb variable throw this error Call to a member function get_results() on a non-object in
- Extend the wp_users table
- Safe way to find last inserted id in a table?
- Database slowdown after update to 3.4.1
- How to use user table of a different database for WordPress users?
- Subscribers to posts
- Get data from database using $WPDB
- Select Multiple meta_value from WP DB; Single Query
- Multiple postmeta with same name for one post in wp_postmeta table
- WP Database Table to CSV file
- Cannot update custom database table row
- Does WordPress always create unique passwords?
- WordPress database error – Error in SQL syntax – I can’t identify any error?
- Change WordPress prefix for only one table?
- Advanced SELECT query with condtional statements
- $wpdb doesn’t like to store arrays
- Select two sums with single get_var statement
- WordPress choose wrong database
- Redirecting to old domain after migration website
- What Is the Proper Way to Merge Usermeta Table to a an existing WP Database?
- Does WordPress $wpdb functions wait when table is locked?
- How Can I Put Meta_Compare in the Database-Query?
- MS Access to manage WordPress Database
- WordPress running SQL query to update database from form
- 2 WordPress sites with 2 databases but sharing the same users
- WPDB SQL query with prepare() returning variable, not db value
- $wpdb error (Call to a member function insert() on a non-object)
- Is it important to have integers inserted using %d rather than %s?
- Is there a way to execute a php script outside WordPress?
- Problem in using wpdb
- Custom WordPress Table wpdb
- Best practice to limit results in get_row()?
- Share users across multiple sites on same database, but with different domains
- Users table missing from Database [closed]
- CreateOrUpdate in WordPress
- Clear Terms from Taxonomy for Specific Post IDs?
- Trouble running $wpdb->query() with last_insert_id
- How to get a list of WordPress default database tables?
- Using $wpdb | checking entered email against existing emails in db
- Optimizing function that automatically creates internal links based on post title string
- How to connect and insert data in database of wordpress?
- Get results from wordpress data custom table
- Outputting query results
- WordPress where clauses in db select
- wp_insert_user not creating account correctly when ID is manually set
- add_post_meta — not working
- Creating and Using Tables in the WordPress Database
- Need help with creating a searchable user data by name or specific number like ID
- $wpdb->insert not inserting all rows
- wpdb Insert unknown post data dynamic foreach loop
- SELECT rows between two datetimes when the range is dynamic [closed]
- How to insert a value to decimal type field using wpdb->prepare?
- Insert NULL value using prepare()
- Display user data in numbered list
- Help with $wpdb on custom code
- “BS_” rows in postmeta table
- $wpdb->insert duplicating rows
- How to rerieve comments and their replies from DB
- Can I use a wpdb object to connect to a non-WordPress Oracle database [duplicate]
- WordPress Database Query works in phpMyAdmin but not in the code
- How to save dropdown slection by a user in the DB
- Correct and secure way to access a custom SQL database in a custom PHP template file
- Using $wpdb to insert data into a table
- update multiple user meta field based on another meta field
- How To connect to the same WordPress database with different database user
- Call to a member function insert()
- I have include wp-config, should I add global $wpdb also?
- Processing a lot of $wpdb isn’t insert all the data
- Can’t Install WordPress (local) Failed to open file wp-includes/wp-db.php
- What WordPress file is saving new users to database
- How can I retrieve data from alternate database using wpdb class?
- WordPress sync with phpbb
- Creating Tables in WordPress Database
- How to use remote db tables in current config? [duplicate]
- $wpdb->prepare returns empty array
- How to delete field using WPDB?
- Uploading to WordPress Database