Skip to content

Commit 1e53e3c

Browse files
author
Dale Nguyen
authored
Merge pull request #4 from mo2l/get_number_of_posts_in_term
Create get_number_of_posts_in_term.php
2 parents 12c03f6 + d3a2d19 commit 1e53e3c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

get_number_of_posts_in_term.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//Show the number of posts in an archive page
2+
3+
//get the term object
4+
$term = get_queried_object();
5+
//get the number of posts in that term
6+
$term->count;
7+
8+
9+
//Show the number of posts of any term by any identifier (e.g. for the term category and the term with id 1)
10+
11+
$term = get_term_by('id', 1, 'category');
12+
$term->count();

0 commit comments

Comments
 (0)