-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtaxonomy.php
136 lines (120 loc) · 4.27 KB
/
taxonomy.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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
/**
* The template for displaying the primary taxonomy terms for the selected custom post type
* - Programming Languages
* - Scratch Archive
* - HTML Archive
* - JavaScript Archive
* - Python Archive
* - App Inventor
* - The Hardware Lab
* - The Studio Archive
* - The Arcade Archive
* - Other Resources Archive
*
* These pages should not display just posts but rather the posts grouped by the resource type
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package CoderDojo
* @subpackage CoderDojo
* @since 1.0.0
*/
get_header();
var_dump($wp_query->query_vars);
$taxonomy = array_keys($wp_query->query_vars)[0];
$term_slug = $wp_query->query_vars[$taxonomy];
var_dump($term_slug);
$terms = array(
get_term_by(
'slug',
$term_slug,
$taxonomy
)
);
$term = $terms[0];
var_dump($term);
global $wp;
$current_url = home_url( $wp->request );
?>
<div class="wp-block-group alignfull hero-section has-white-color has-text-color has-background" style="background-color:#642580">
<div class="wp-block-group__inner-container">
<h1 class="section-heading"><?php echo $section_title; ?></h1>
<img id="hero-image" class="wrapper" src="<?php bloginfo('template_url');?>/assets/images/header-image.png" />
</div>
</div>
<main>
<article id="article-wrapper" class="wrapper spacer">
<p class="section-description"><?php echo $section_description; ?></p>
</article>
<aside id="aside-wrapper" class="wrapper spacer">
<?php if ($taxonomy == 'groups'){
$section_title = $term->name;
$section_description = $term->description;
if($term->parent == 0){
var_dump('First Group');
$terms = coderdojo_kata_get_group_terms($term->term_id);
var_dump($terms);
echo '<ul class="section-list">';
foreach($terms as $term):
//if($term->count > 0):
echo '<li class="section-list-item sushi-cards">';
echo '<a class="card-link" href="'. get_term_link($term).'">';
echo '<img class="card-img" src="' . get_bloginfo('template_url') . '/assets/images/' . $term->slug . '.png" />';
echo '<h3 class="card-heading">' . $term->name . '</h3>';
echo '<p class="card-description">' . $term->description . '</p>';
echo '</a>';
echo '</li>';
//endif;
endforeach;
echo '</ul>';
} else {
foreach($terms as $term):
$args = array(
'numberposts' => $number_posts,
'post_type' => 'sushi-deck',
'relation' => 'AND',
'tax_query' => array(
array(
'taxonomy' => 'groups',
'field' => 'slug',
'terms' => $primary_term
),
array(
'taxonomy' => 'groups',
'field' => 'slug',
'terms' => $term->slug
)
)
);
$posts = get_posts( $args );
if(!empty($posts)) {
echo '<section class="section">';
echo '<h2 class="section-heading">' . $term->name . '</h2>';
echo '<p class="section-description">' . $term->description . '</p>';
echo '<ul class="section-list">';
$count = 0;
foreach ($posts as $post):
get_template_part('template-parts/content/link-card');
++$count;
endforeach;
if($count == 5) :
echo '<li class="section-list-item sushi-cards">';
echo '<a class="card-link" href="' . $current_url . '/' . $term->slug . '">';
echo '<h3 class="card-heading">View All</h3>';
echo '</a>';
echo '</li>';
endif;
echo '</ul>';
echo '</section>';
}
endforeach;
var_dump('Second Group');
}
} else {
var_dump('Resource Type');
}
?>
</aside>
</main>
<?php get_footer(); ?>