I'm using PHP everywhere plugin to insert PHP snippets in my page. Specifically, I'm trying to get posts count in a category. Here's my code:
<?php
$count=get_category(607)->count;
echo $count;
?>
But it doesn't display any value, and there is no way of checking what it is returning. The plugin works fine. For example, if I enter echo 1+1
it displays 2.
Please help me. Thanks in advance
I'm using PHP everywhere plugin to insert PHP snippets in my page. Specifically, I'm trying to get posts count in a category. Here's my code:
<?php
$count=get_category(607)->count;
echo $count;
?>
But it doesn't display any value, and there is no way of checking what it is returning. The plugin works fine. For example, if I enter echo 1+1
it displays 2.
Please help me. Thanks in advance
1 Answer
Reset to default 1This answer Count how many posts in category says to use this code
$category = get_category($id);
$count = $category->category_count;
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745433825a4627515.html
评论列表(0条)