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

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

如何使用短代碼顯示 WooCommerce 我的帳戶儀表板

如何使用短代碼顯示 WooCommerce 我的帳戶儀表板

PHP
瀟湘沐 2023-07-21 16:30:16
我有一個自定義 myaccount 頁面,我想在其中顯示儀表板.php。我們如何dashboard.php在短代碼中嵌入模板(我的帳戶“儀表板”)?我在我的中嘗試了以下操作functions.php://[account_dashboard]add_shortcode('account_dashboard', 'display_account_dashboard');function display_account_dashboard(){? ? return WC_Shortcode_My_Account::dashboard();}但這不起作用
查看完整描述

1 回答

?
慕田峪7331174

TA貢獻1828條經驗 獲得超13個贊

更新:?添加了缺少的定義參數“current_user”

要將模板myaccount/dashboard.php嵌入到短代碼中,您可以通過以下方式使用該函數wc_get_template()

add_shortcode('account_dashboard', 'display_account_dashboard');

function display_account_dashboard()

{

? ? return wc_get_template(

? ? ? ? 'myaccount/dashboard.php',

? ? ? ? array(

? ? ? ? ? ? 'current_user' => get_user_by( 'id', get_current_user_id() )

? ? ? ? )

? ? );

代碼位于活動子主題(或活動主題)的functions.php 文件中。經過測試并有效。


用法: [account_dashboard]


查看完整回答
反對 回復 2023-07-21
  • 1 回答
  • 0 關注
  • 120 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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