下記のURL
(https://www.atomicsmash.co.uk/blog/customising-the-woocommerce-my-account-section/)
- Add a new menu tab and content
に該当する部分を参考に、
以下のコードを子テーマのfunction.phpに追加し、
/** * Register new endpoints to use inside My Account page. */ add_action( 'init', 'my_account_new_endpoints' ); function my_account_new_endpoints() { add_rewrite_endpoint( 'awards', EP_ROOT | EP_PAGES ); }
/** * Get new endpoint content */ // Awards add_action( 'woocommerce_account_awards_endpoint', 'awards_endpoint_content' ); function awards_endpoint_content() { get_template_part('my-account-awards'); }
子テーマと一緒のフォルダに、my-account-awards.phpを作成、
そのphpファイルに以下のコード
<?php echo 'Awards Section'; /** * Edit my account menu order */ function my_account_menu_order() { $menuOrder = array( 'dashboard' => __( 'Dashboard', 'woocommerce' ), 'awards' => __( 'Awards', 'woocommerce' ), 'orders' => __( 'Orders', 'woocommerce' ), 'downloads' => __( 'Downloads', 'woocommerce' ), 'edit-address' => __( 'Addresses', 'woocommerce' ), 'payment-methods' => __( 'Payment methods', 'woocommerce' ), 'edit-account' => __( 'Account details', 'woocommerce' ), 'customer-logout' => __( 'Logout', 'woocommerce' ), ); return $menuOrder; } add_filter ( 'woocommerce_account_menu_items', 'my_account_menu_order' );
を記入したのですが、
下記の画像のようにタブメニューAwardsが追加されません。
その代わりにmy-account/awardsのリンクに飛んだ際、
上記のコードに追加したecho 'Awards Section';に該当する部分は表示されています。
また、
自分はこの新たに作成する予定のメニュータブ(下記の画像だとAwardsのタブに該当)
に対して既存のリンク先を設定したいのですが可能なのでしょうか?
あなたの回答
tips
プレビュー