/wp-content/themes/wp-foundation-interocc/page-directory-members.php

https://gitlab.com/Blueprint-Marketing/interoccupy.net · PHP · 116 lines · 77 code · 29 blank · 10 comment · 9 complexity · 4f2bd62f6fcfbbfd33746284c06a659e MD5 · raw file

  1. <?php
  2. /*
  3. Template Name: InterOcc Member Directory
  4. */
  5. ?>
  6. <?php get_header(); ?>
  7. <div id="content">
  8. <div id="main" class="twelve columns" role="main">
  9. <article role="article">
  10. <header>
  11. </header>
  12. <section class="row post_content">
  13. <?php get_sidebar(); // sidebar 1 ?>
  14. <div class="nine columns">
  15. <?php the_content(); ?>
  16. <!-- start blog directory -->
  17. <?php
  18. // Get the authors from the database ordered randomly
  19. global $wpdb;
  20. $query = "SELECT ID, user_nicename from $wpdb->users WHERE ID != '1' ORDER BY RAND() LIMIT 50";
  21. $author_ids = $wpdb->get_results($query);
  22. // Loop through each author
  23. foreach($author_ids as $author) {
  24. // Get user data
  25. $curauth = get_userdata($author->ID);
  26. // Get link to author page
  27. $user_link = get_author_posts_url($curauth->ID);
  28. // Get blog details for the authors primary blog ID
  29. $blog_details = get_blog_details($curauth->primary_blog);
  30. if ($blog_details->post_count == "1") {
  31. $postText = "post ";
  32. }
  33. else if ($blog_details->post_count >= "2") {
  34. $postText = "posts";
  35. }
  36. else {
  37. $postText = "posts";
  38. }
  39. $updatedOn = strftime("%m/%d/%Y at %l:%M %p",strtotime($blog_details->last_updated));
  40. if ($blog_details->post_count == "") {
  41. $blog_details->post_count = "0";
  42. }
  43. $posts = $wpdb->get_col( "SELECT ID FROM wp_".$curauth->primary_blog."_posts WHERE post_status='publish' AND post_type='post' AND post_author='$author->ID' ORDER BY ID DESC LIMIT 5");
  44. $postHTML = "";
  45. $i=0;
  46. foreach($posts as $p) {
  47. $postdetail=get_blog_post($curauth->primary_blog,$p);
  48. if ($i==0) {
  49. $updatedOn = strftime("%m/%d/%Y at %l:%M %p",strtotime($postdetail->post_date));
  50. }
  51. $postHTML .= "&#149; <a href=\"$postdetail->guid\">$postdetail->post_title</a><br />";
  52. $i++;
  53. }
  54. ?>
  55. <div class="author_bio">
  56. <div class="row">
  57. <div class="column grid_2">
  58. <a href="<?php echo $blog_details->siteurl; ?>"><?php echo get_avatar($curauth->user_email, '96','http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536'); ?></a>
  59. </div>
  60. <div class="column grid_6">
  61. <a href="<?php echo $blog_details->siteurl; ?>" title="<?php echo $curauth->display_name; ?> - <?=$blog_details->blogname?>"><?php //echo $curauth->display_name; ?> <?=$curauth->display_name;?></a><br />
  62. <small><strong>Updated <?=$updatedOn?></strong></small><br />
  63. <?php echo $curauth->description; ?>
  64. </div>
  65. <div class="column grid_3">
  66. <h3>Recent Posts</h3>
  67. <?=$postHTML?>
  68. </div>
  69. </div>
  70. <span class="post_count"><a href="<?php echo $blog_details->siteurl; ?>" title="<?php echo $curauth->display_name; ?>"><?=$blog_details->post_count?><br /><?=$postText?></a></span>
  71. </div>
  72. <?php } ?>
  73. <!-- end blog directory -->
  74. </div>
  75. <?php// get_sidebar('sidebar2'); // sidebar 2 ?>
  76. </section> <!-- end article header -->
  77. <footer>
  78. <p class="clearfix"><?php the_tags('<span class="tags">Tags: ', ', ', '</span>'); ?></p>
  79. </footer> <!-- end article footer -->
  80. </article> <!-- end article -->
  81. <?php
  82. // No comments on homepage
  83. //comments_template();
  84. ?>
  85. </div> <!-- end #main -->
  86. </div> <!-- end #content -->
  87. <?php get_footer(); ?>