Guest User

Untitled

a guest
Mar 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. // Set up arguments for query.
  2. $args = [
  3. 'has_published_posts' => [ 'page' ],
  4. 'orderby' => 'post_count',
  5. 'order' => 'DESC',
  6. ];
  7.  
  8. // Create the WP_User_Query object
  9. $user_query = new WP_User_Query( $args );
  10.  
  11. // Get results.
  12. $users = $user_query->get_results();
  13.  
  14. // Check for results
  15. if ( ! empty( $users ) ) {
  16. echo '<ul>' . PHP_EOL;
  17.  
  18. // Loop through each author.
  19. foreach ( $users as $user ) {
  20. // Get all the user's data.
  21. $user_info = get_userdata( $user->ID );
  22. echo "t" . '<li>' .
  23. '<em>' . __( 'User ID: ', 'text-domain' ) . esc_html( $user->ID ) . '</em> ' .
  24. esc_html( $user_info->first_name ) . ' ' .
  25. esc_html( $user_info->last_name ) .
  26. '</li>' . PHP_EOL;
  27. }
  28.  
  29. echo '</ul>' . PHP_EOL;
  30. } else {
  31. echo __( 'No authors found', 'text-domain' );
  32. }
Add Comment
Please, Sign In to add comment