forked from tareq1988/wedocs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
archive.php
51 lines (41 loc) · 1.26 KB
/
archive.php
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
<?php
$parent_cat = get_queried_object();
$categories = get_terms( 'category', array('hide_empty' => false, 'orderby' => 'term_id', 'parent' => $parent_cat->term_id) );
if ( $categories ) {
printf( '<h2 class="category-title">%s</h2>', $parent_cat->name );
echo '<ul class="doc-category clearfix">';
foreach ( $categories as $category ) {
include 'templates/loop-category.php';
}
echo '</ul>';
}
// WP_Query arguments
$args = array(
'post_type' => 'post',
'category__in' => array( $parent_cat->term_id ),
'posts_per_page' => -1,
'order' => 'ASC',
'orderby' => 'post_date'
);
// The Query
$doc_query = new WP_Query( $args );
// The Loop
if ( $doc_query->have_posts() ) {
printf( '<h2 class="category-title">%s</h2>', __( 'Documents', 'wedevs-docs' ) );
echo '<ul class="doc-category">';
while ($doc_query->have_posts()) {
$doc_query->the_post();
get_template_part( 'templates/loop-content' );
}
echo '</ul>';
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
?>
<?php if ( !$categories && !$doc_query->have_posts() ) { ?>
<div class="alert alert-warning">
<?php _e( 'Nothing found!', 'wedevs-docs' ); ?>
</div>
<?php } ?>