SHARE
TWEET

groups forums taxonomy template

a guest Jan 9th, 2017 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * taxonomy-forum.php
  4.  *
  5.  * This is the default template for Forums (forum taxonomy).
  6.  *
  7.  * To modify this template:
  8.  * - Create a groups-forums subfolder in your theme's root folder.
  9.  * - Copy this file there and adjust it as desired.
  10.  *
  11.  * @author itthinx
  12.  * @package groups-forums
  13.  * @since groups-forums 1.0.0
  14.  */
  15.  
  16. get_header();
  17.  
  18. echo '<div id="primary" class="site-content forum">';
  19. echo '<div id="content">';
  20.  
  21. // title & New Topic link
  22. if ( is_tax() ) {
  23.     global $wp_query;
  24.     if ( $forum = $wp_query->get_queried_object() ) {
  25.         if ( $forum && !is_wp_error( $forum ) ) {
  26.             echo sprintf( '<h1 class="forum-title %s">%s</h1>', $forum->slug, wp_strip_all_tags( $forum->name ) );
  27.             echo '<br/>';
  28.             $user_id  = get_current_user_id();
  29.             if ( Groups_Forums::user_can_post( $user_id, $forum->term_id ) ) {
  30.                 $edit_topic_post_id = Groups_Options::get_option( 'groups-forums-edit-topic-post-id', null );
  31.                 if ( $edit_topic_post_id ) {
  32.                     $link = add_query_arg( 'forum_id', $forum->term_id, get_permalink( $edit_topic_post_id ) );
  33.                     echo '<div class="new-topic">';
  34.                     echo sprintf( '<a href="%s">%s</a>', $link, __( 'Post a new Topic', GROUPS_FORUMS_PLUGIN_DOMAIN ) );
  35.                     echo '</div>';
  36.                     echo '<br/>';
  37.                 }
  38.             }
  39.         }
  40.     }
  41. }
  42.  
  43. $term_id = $forum->term_id;
  44. $taxonomy_name = 'forum';
  45. $termchildren = get_term_children( $term_id, $taxonomy_name );
  46.  
  47. if ( sizeof( $termchildren ) > 0 ) {
  48.  
  49.     echo '<ul>';
  50.     foreach ( $termchildren as $child ) {
  51.         $term = get_term_by( 'id', $child, $taxonomy_name );
  52.         echo '<li><a href="' . get_term_link( $child, $taxonomy_name ) . '">' . $term->name . '</a></li>';
  53.     }
  54.     echo '</ul>';
  55.  
  56. } else {
  57.  
  58.     // forum topics
  59.     while ( have_posts() ) {
  60.         the_post();
  61.         get_template_part( 'content', get_post_format() );
  62.     }
  63.  
  64.     // pagination
  65.     global $wp_query;
  66.     $paginate_links = paginate_links( array(
  67.         'base'    => str_replace( PHP_INT_MAX, '%#%', esc_url( get_pagenum_link( PHP_INT_MAX ) ) ),
  68.         'format'  => '?paged=%#%',
  69.         'current' => max( 1, get_query_var('paged') ),
  70.         'total'   => $wp_query->max_num_pages
  71.     ) );
  72.     if ( strlen( $paginate_links ) > 0 ) {
  73.         echo '<div class="paginate-links">';
  74.         echo $paginate_links;
  75.         echo '</div>';
  76.     }
  77.  
  78. }
  79.  
  80. echo '</div>';
  81. echo '</div>';
  82.  
  83. get_sidebar();
  84. get_footer();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top