Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions get_number_of_posts_in_term.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//Show the number of posts in an archive page

//get the term object
$term = get_queried_object();
//get the number of posts in that term
$term->count;


//Show the number of posts of any term by any identifier (e.g. for the term category and the term with id 1)

$term = get_term_by('id', 1, 'category');
$term->count();