categories - Why get_category() function is not working not working when embedded in a page?

I'm using PHP everywhere plugin to insert PHP snippets in my page. Specifically, I'm trying to get posts count

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

Share Improve this question asked Jun 6, 2019 at 1:55 SanSoloSanSolo 1035 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

This 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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信