Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. <?php
  2.  
  3. define('WP_USE_THEMES', false);
  4. require('/home/fomana/webapps/vncblog/wp-load.php');
  5.  
  6. //Get users and count of posts put into array $uc, sort array by post count ascending, loop through array and echo user info, get latest post for each user and display time and title
  7. $uc = array();
  8. $blogusers = get_users_of_blog();
  9. if ($blogusers) {
  10. foreach ($blogusers as $bloguser) {
  11. $post_count = get_usernumposts($bloguser->user_id);
  12. $uc[$bloguser->user_id]=$post_count;
  13. }
  14. arsort($uc); //use asort($uc) if ascending by post count is desired
  15. $maxauthor = 10; // max authors to display
  16. $count = 0;
  17. foreach ($uc as $key => $value) {
  18. $count++;
  19. if ($count <= $maxauthor) {
  20. $user = get_userdata($key);
  21. $author_posts_url = get_author_posts_url($key);
  22. $post_count = $value;
  23.  
  24. // Output the user info
  25. ?>
  26. <div class="block">
  27. <img class="fruit" src="<?php echo show_fruit(get_the_time('U'))?>" />
  28. <h3><?php echo $user->user_firstname . ' ' . $user->user_lastname ?></h3>
  29. <a href="<?php echo $author_posts_url ?>">View Posts</a>
  30. <?php
  31. $args=array(
  32. 'showposts' => 1,
  33. 'author' => $user->ID,
  34. 'caller_get_posts' => 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement