-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_terms.php
More file actions
42 lines (34 loc) · 1.02 KB
/
get_terms.php
File metadata and controls
42 lines (34 loc) · 1.02 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
<?php
// Get categories from specific post type taxonomy
// filtering_category = Taxonomy name
// hide_empty = empty category will show or not
$all_terms = get_terms('filtering_category', array(
'hide_empty' => false
));
foreach($all_terms as $single_term){
echo '<li class="filter" data-filter=".' . $single_term->slug . '">' . $single_term->name . '</li>';
}
// get_terms returns as below objects
array(1) {
[0]=>
object(WP_Term) (11) {
["term_id"]=> //int
["name"]=> //string
["slug"]=> //string
["term_group"]=> //int
["term_taxonomy_id"]=> //int
["taxonomy"]=> //string
["description"]=> //string
["parent"]=> //int
["count"]=> // int
["filter"]=> //string
["meta"]=> array(0) { // presumably this would be some returned meta-data?
}
}
}
// Get all post categories ordered by count.
$categories = get_terms( 'category', array(
'orderby' => 'count',
'hide_empty' => 0
) );
?>