首页 > 解决方案 > 转发器 ACF 子域的计数

问题描述

我想计算转发器 ACF 的子字段的数量作为我的代码

<?php
   $cards = get_sub_field('agence_post');
   if(have_rows('agence_post')):
      $number_of_cards = count($cards);
      echo $number_of_cards;
  endif;
?>

标签: phpwordpressadvanced-custom-fields

解决方案


您好您可以使用此功能获取子字段

<?php $numrows = count( get_sub_field( 'agence_post' ) );
  echo $numrows;?>

推荐阅读