Count how many posts in category


This is what I’m trying to do:

if number of posts is greater than 20 -> display link to another page (which shows all posts)
if number of posts is less than 20 -> don’t display the link

So far I’ve been able to return the number of posts using

$count_posts = wp_count_posts('inventory');
$published_posts = $count_posts->publish;

but I don’t know where to go from here, any suggestions?

, maikunari 3 years 2020-04-04T00:55:33-05:00 0 Answers 68 views 0

Leave an answer