WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to list authors with last post data and order them by last post date. Now i have this codes but i don`t know how to edit them.

// Selects from tables wp_users and wp_posts, selecting published posts and ordering by its post_date, limited to 10
        $querystr = "SELECT * from wp_users, wp_posts WHERE wp_users.ID = wp_posts.post_author AND wp_posts.post_type = 'post' AND wp_posts.post_status = 'publish' ORDER BY wp_posts.post_date DESC LIMIT 10";

          $news=$wpdb->get_results($querystr, OBJECT);

          foreach($news as $np)
            $authorID = $np->authorID;
            $author_nickname = $np->user_login;
            $author_displayName = $np->display_name;
            $author_niceName = $np->user_nicename;
            $post_id= $np->postID;
            $post_title= $np->post_title;
            $post_date= $np->post_date;

or this :

//displays all users with their avatar and their posts (titles)
$blogusers = get_users_of_blog();
if ($blogusers) {
foreach ($blogusers as $bloguser) {
$user = get_userdata($bloguser->user_id);
echo '<p>User ID ' . $user->ID . ' ' . $user->user_firstname . ' ' .      $user->user_lastname . '</p>';
  echo get_avatar( $user->ID, 46 );
  'author' => $user->ID,
  'post_type' => 'post',
  'post_status' => 'publish',
  'posts_per_page' => -1,
  'caller_get_posts'=> 1
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
  //echo 'List of Posts for ' . user->user_firstname . ' ' . $user->user_lastname;
  while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to    <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
  wp_reset_query();  // Restore global post data stomped by the_post().
share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.