-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaxonomy-forum.php
More file actions
100 lines (59 loc) · 2.13 KB
/
taxonomy-forum.php
File metadata and controls
100 lines (59 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php get_header( 'forums' ); ?>
<main id="main-forums">
<div class="c nav-padding">
<?php get_template_part( 'forums', 'breadcrumbs' ); ?>
<header id="forums-header">
<h1><?php single_cat_title(); ?></h1>
<p>
<?php echo get_queried_object()->description; ?>
</p>
<hr>
</header>
<section class="forums-subforums">
<?php $sub_forums = get_term_children( get_queried_object()->term_id, 'forum' ); ?>
<?php if ( !empty( $sub_forums ) ): ?>
<h2 class="forums-subheader">Subforums</h2>
<?php foreach ( $sub_forums as $forum ): $forum = get_term( $forum, 'forum' ); ?>
<?php get_template_part( 'forums', 'loop-forums' ); ?>
<?php endforeach; ?>
<br><hr>
<?php endif; ?>
</section>
<section class="forums-posts">
<h2 class="forums-subheader">Threads</h2>
<?php
$tax_query = new WP_Query( array(
'posts_per_page' => get_option( 'posts_per_page' ),
'paged' => get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1,
'tax_query' => array(
array(
'taxonomy' => 'forum',
'field' => 'term_id',
'terms' => get_queried_object()->term_id,
'include_children' => false,
),
),
));
$paginate = (bool) $tax_query->have_posts();
?>
<?php if ( $tax_query->have_posts() ): ?>
<?php while ( $tax_query->have_posts() ): $tax_query->the_post(); ?>
<?php get_template_part( 'forums', 'loop-threads' ); ?>
<?php endwhile; ?>
<?php else: ?>
<h3 class="no-posts">No threads</h3>
<?php endif; ?>
</section>
<?php if ( $paginate ): ?>
<?php get_template_part( 'forums', 'pagination' ); ?>
<?php endif; ?>
<?php if ( current_user_can( 'publish_forum_threads' ) ): ?>
<form class="forums-new-thread" method="POST">
<br><hr>
<h2 class="forums-subheader">New Thread</h2>
<?php get_template_part( 'forums', 'form-thread-new' ); ?>
</form>
<?php endif; ?>
</div>
</main>
<?php get_footer( 'forums' ); ?>