Advertisement
Guest User

loop-forums.php

a guest
Feb 25th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Forums Loop
  5. *
  6. * @package bbPress
  7. * @subpackage Theme
  8. * Code from: http://bbpress.org/forums/topic/forums-index-in-the-same-layout-as-other-bb-software/
  9. */
  10.  
  11. ?>
  12.  
  13. <?php do_action( 'bbp_template_before_forums_loop' ); ?>
  14.  
  15. <?php while ( bbp_forums() ) : bbp_the_forum();
  16.  
  17. /* We print the header only if we want to show a category or if it's the first item of a no-parent forum list */
  18. if (bbp_is_forum_category() OR !$bbp_forums_noheader)
  19. { ?>
  20.  
  21. <ul id="forums-list-<?php bbp_forum_id(); ?>" class="bbp-forums">
  22.  
  23. <li class="bbp-header">
  24.  
  25. <ul class="forum-titles">
  26. <li class="bbp-forum-info"><?php if(bbp_is_forum_category()) { ?><a class="bbp-forum-title" href="<?php bbp_forum_permalink(bbp_get_forum_parent_id()); ?>"><?php bbp_forum_title(bbp_get_forum_parent_id()); ?></a><?php } else { _e( 'Forum', 'bbpress' ); } ?></li>
  27. <li class="bbp-forum-topic-count"><?php _e( 'Topics', 'bbpress' ); ?></li>
  28. <li class="bbp-forum-reply-count"><?php bbp_show_lead_topic() ? _e( 'Replies', 'bbpress' ) : _e( 'Posts', 'bbpress' ); ?></li>
  29. <li class="bbp-forum-freshness"><?php _e( 'Freshness', 'bbpress' ); ?></li>
  30. </ul>
  31.  
  32. </li><!-- .bbp-header -->
  33. <?php } ?>
  34.  
  35. <li class="bbp-body">
  36.  
  37. <?php /* If the forum is a category, we're gonna make another loop to show its subforums and sub-subforums as if those were forums */
  38. if(bbp_is_forum_category())
  39. {
  40.  
  41. $temp_query = clone bbpress()->forum_query;
  42. bbp_has_forums('post_parent='.bbp_get_forum_id());
  43. while ( bbp_forums() ) : bbp_the_forum();
  44. bbp_get_template_part( 'loop', 'single-forum' );
  45. endwhile;
  46. bbpress()->forum_query = clone $temp_query;
  47.  
  48. }
  49. else /* Otherwise, we print the forums the normal way */
  50. {
  51.  
  52. bbp_get_template_part( 'loop', 'single-forum' );
  53. $bbp_forums_noheader = 1; /* This prevents the header part to be printed again on next post in the loop */
  54.  
  55. } ?>
  56.  
  57. </li><!-- .bbp-body -->
  58.  
  59. <?php /* Prints the footer only if :
  60. - it's a category
  61. - or if it's the last forum of a no-parent forum list
  62. - or if the next forum in the loop is a category */
  63.  
  64. if( bbp_is_forum_category()
  65. OR (bbpress()->forum_query->current_post+1) == bbpress()->forum_query->post_count
  66. OR bbp_is_forum_category(bbpress()->forum_query->posts[ bbpress()->forum_query->current_post + 1 ]->ID))
  67. { ?>
  68.  
  69. <li class="bbp-footer">
  70.  
  71. <div class="tr">
  72. <p class="td colspan4">&nbsp;</p>
  73. </div><!-- .tr -->
  74.  
  75. </li><!-- .bbp-footer -->
  76.  
  77. </ul><!-- .forums-directory -->
  78.  
  79. <?php unset($bbp_forums_noheader); /* Needed if we have 2+ no-parent forums with at least 1 category between them */
  80. } ?>
  81.  
  82. <?php endwhile; ?>
  83.  
  84.  
  85.  
  86. <?php do_action( 'bbp_template_after_forums_loop' ); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement