Advertisement
Guest User

loop-forums

a guest
Apr 19th, 2014
83
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /**
  4.  * Forums Loop
  5.  *
  6.  * @package bbPress
  7.  * @subpackage Theme
  8.  */
  9.  
  10. ?>
  11.  
  12. <?php do_action( 'bbp_template_before_forums_loop' ); ?>
  13.  
  14. <?php while ( bbp_forums() ) : bbp_the_forum();
  15.        
  16.         /* 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 */
  17.         if (bbp_is_forum_category() OR !$bbp_forums_noheader)
  18.             { ?>
  19.  
  20.             <ul id="forums-list-<?php bbp_forum_id(); ?>" class="bbp-forums">
  21.  
  22.                 <li class="bbp-header">
  23.  
  24.                     <ul class="forum-titles">
  25.                         <li class="bbp-forum-info"><?php bbp_get_forum_parent_id(); ?><?php bbp_forum_title(bbp_get_forum_parent_id()); ?></a></li>
  26.                         <li class="bbp-forum-topic-count"><?php _e( 'Topics', 'bbpress' ); ?></li>
  27.                         <li class="bbp-forum-reply-count"><?php bbp_show_lead_topic() ? _e( 'Replies', 'bbpress' ) : _e( 'Posts', 'bbpress' ); ?></li>
  28.                         <li class="bbp-forum-freshness"><?php _e( 'Latest Post', 'bbpress' ); ?></li>
  29.                     </ul>
  30.  
  31.                 </li><!-- .bbp-header -->
  32. <?php       } ?>
  33.  
  34.             <li class="bbp-body">
  35.    
  36. <?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 */
  37.             if(bbp_is_forum_category())
  38.                 {
  39.  
  40.                 $temp_query = clone bbpress()->forum_query;
  41.                 bbp_has_forums('post_parent='.bbp_get_forum_id());
  42.                 while ( bbp_forums() ) : bbp_the_forum();
  43.                 bbp_get_template_part( 'loop', 'single-forum' );
  44.                 endwhile;
  45.                 bbpress()->forum_query = clone $temp_query;
  46.  
  47.                 }
  48.                     else /* Otherwise, we print the forums the normal way */
  49.                 {  
  50.  
  51.                 bbp_get_template_part( 'loop', 'single-forum' );
  52.                 $bbp_forums_noheader = 1; /* This prevents the header part to be printed again on next post in the loop */
  53.  
  54.                 } ?>
  55.  
  56.             </li><!-- .bbp-body -->
  57.  
  58.  
  59.  
  60.         </ul><!-- .forums-directory -->
  61.  
  62. <?php   unset($bbp_forums_noheader); /* Needed if we have 2+ no-parent forums with at least 1 category between them */
  63.           ?>
  64.  
  65. <?php endwhile; ?>
  66.  
  67.  
  68. <?php do_action( 'bbp_template_after_forums_loop' ); ?>
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement