第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在自定義帖子類型 ACF WORDPRESS 的同一字段中計算()值

如何在自定義帖子類型 ACF WORDPRESS 的同一字段中計算()值

PHP
躍然一笑 2022-10-22 15:29:14
我的自定義帖子類型中有字段名稱“金額”,我想要的只是每次我使用通過 ACF 創(chuàng)建的金額字段發(fā)布時都會計數(shù)()字段金額前任。loop  // The task is a post in custom post type different amount   // the first value post ex. 10, Second post 20, Third post will be 30  // I am trying this but not work  $varAmount = get_field('amount');  $varCount = count($varAmount); echo $varCount;  Output expected is: 60  // but showing 1010101;  // how to do that 60 instead of 101010?/loop$faq = new  WP_Query($args_faqs);if ( $faq->have_posts() ) {/* * Begin the loop tags post */    #echo count(get_field('loan_amount_applied'));     $total_amount = 0;      $amountapplied = get_field('loan_amount_applied');      $total_amount += $amountapplied;      $varCount = count($total_amount);      // array() = $amountapplied);     // if(is_array($amountappliedCOntainer)) {     // $total_amount = count($amountappliedCOntainer);while ( $faq->have_posts() ) {         $faq->the_post();
查看完整描述

1 回答

?
HUWWW

TA貢獻1874條經驗 獲得超12個贊

由于您需要計算多個帖子的值,因此您需要在循環(huán)外初始化一個值為 0 的變量。然后您需要將金額(ACF FIELD)的值添加到該變量,然后回顯它。


使用下面的代碼。


<?php if ( have_posts() ) : 


$counter = 0;


/* Start the Loop */

while ( have_posts() ) :

the_post();

$varAmount = get_field('amount');

$counter += $varAmount;

echo $counter;

endwhile;


endif;

?>


查看完整回答
反對 回復 2022-10-22
  • 1 回答
  • 0 關注
  • 90 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號