亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

wordpress 中的總自定義帖子類型

wordpress 中的總自定義帖子類型

PHP
慕無忌1623718 2022-12-23 16:13:59
你好,在這個插件中,我為 cpt1 和 cpt2 寫了這 2 個代碼總帖子,現在我希望代碼獲得這 2 個 CPT 自定義帖子類型的總數 /// 這意味著 // menha_dir_ltg + mobadra1_dir_ltg = ??? 任何的想法//this is to count totala custom post -- mobadra2_dir_ltg - ta7tag da3madd_shortcode('total-listing-counter-menha','total_listing_counter?menha');function total_listing_counter?menha(){ $count_posts = wp_count_posts( 'menha_dir_ltg' )->publish; return $count_posts;}//this is to count totala custom post -- mobadra1_dir_ltg - ta7tag da3madd_shortcode('total-listing-counter-ta7tag-da3m','total_listing_counter?ta7tag?da3m');function total_listing_counter?ta7tag?da3m(){ $count_posts = wp_count_posts( 'mobadra1_dir_ltg' )->publish; return $count_posts;}
查看完整描述

1 回答

?
慕碼人8056858

TA貢獻1803條經驗 獲得超6個贊

您只需將兩者結合在第三個簡碼中并更新“$total_count”變量:


add_shortcode('total-listing-counter','total_listing_counter');


function total_listing_counter(){


     $count_menha_dir_ltg_posts = wp_count_posts( 'menha_dir_ltg' )->publish;

     $count_mobadra1_dir_ltg_posts = wp_count_posts( 'mobadra1_dir_ltg' )->publish;

     $total_count = count_menha_dir_ltg_posts + $count_mobadra1_dir_ltg_posts;


     return $total_count;


}


查看完整回答
反對 回復 2022-12-23
  • 1 回答
  • 0 關注
  • 103 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

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

公眾號

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