MySQL Order before Group by

后端 未结 10 1183
渐次进展
渐次进展 2020-11-27 04:41

I need to find the latest post for each author and then group the results so I only a single latest post for each author.

SELECT wp_posts.* FROM wp_posts
            


        
10条回答
  •  青春惊慌失措
    2020-11-27 04:51

    Use the below code...

     $bloguser->user_id,
          'showposts' => 1,
          'caller_get_posts' => 1
        );
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          // $user = get_userdata($bloguser->user_id);
          // echo 'This is one post for author with User ID: ' . $user->ID . ' ' . $user-    >user_firstname . ' ' . $user->user_lastname;
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
            
    
             by      
    

提交回复
热议问题