Display list of user with most most orderby post count ASC or DESC
-
How to display list of user with most post orderby post count ASC or DESC, I have tried using WP_Query, and wp_user_query, but none of them can orderby postcount ASC/DESC, is there a way without wpdb query.
Name Number of post ASC/DESC
ueser x 50
user y 40
user u 20Here I have an example using WP_Query, I need to learn interaction database like sql to achieve what I want
<?php $args = array ( 'post_type' => 'post', 'posts_per_page' => '16', ); $the_query = new WP_Query ($args); if ($the_query-> have_posts()) { $authorArgs = array( 'orderby' => 'ID', 'posts_per_page' => 1, 'has_published_posts' => array('post'), ); $authors = get_users(); $authors = get_users( array( 'user_registered' => 'blankwordpress' ) ); echo '<table> <tr> <th>Company</th> <th>Contact</th> <th>Country</th> </tr> '; foreach ( $authors as $author ) { $posts = count_user_posts($author->ID, 'post'); echo '<tr><td>' . esc_html( $author->first_name) .' </td><td>' . esc_html( $author->last_name) . '</td><td> ' . $posts . '</td></tr>'; echo '</table>'; echo '<ul>'; while ($the_query-> have_posts()) { $the_query-> the_post(); echo '<li>'. get_the_title(). '</li>'; echo '<li>'. get_the_author(). '</li>'; } echo '</ul>'; } else { // no posts found } ?>
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Display list of user with most most orderby post count ASC or DESC’ is closed to new replies.