一直在看类似的问题,但仍然不确定:
我可以使用if语句根据类别名称限制我的总和吗?
<?php
$c = 0;
if ( have_posts() ) :
while ( have_posts() ) :
the_post();
if (get_the_category()=="Uncategorized") :
$c++;
endif;
endwhile;
endif;
echo "Count = $c";
?>
如果我理解对了问题,你应该能够添加这样的东西到你的if
if (get_the_category()=="Uncategorized" && $c < 5) :
if
语句中的内容只会对$c < 5
执行