如何从自定义帖子类型和分类法中获取已发布帖子的数量。
我有自定义帖子类型:拖车,分类法:trailere noi
<?php
$items = get_posts( array(
\'post_type\' => \'trailers\',
\'numberposts\' => -1,
\'taxonomy\' => \'trailere-noi\',
));
$count = count( $posts );
echo $count;
?>
我用这个代码来描述帖子的显示方式。。如何获得该分类法中所有帖子的计数?响应:
<?php
$related_posts = get_field( \'subtitrare_film\' );
$count = count( $related_posts );
echo $count;
?>
Subitrare\\u film-是Relathip字段(信息:http://www.advancedcustomfields.com/docs/field-types/relationship/)此代码检索字段计数编号,但问题是:如果该自定义字段(关系fild)没有任何数据,则检索编号1,我希望显示0(如果没有数据)