如何将功能中的内容放置在Woocommerce的“我的帐户”中?
问题描述:
嗨,我有这个功能,插入的functions.php在我的主题:如何将功能中的内容放置在Woocommerce的“我的帐户”中?
function woocommerce_after_account_navigation(){
$html = '<h3>Title</h3>';
$html.='<li><a href="link">Text1</a></li>';
$html.='<li><a href="link">Text2</a></li>';
echo $html;
}
,并放置在此勾成navigation.php文件从WooCommerce模板
<?php do_action('woocommerce_after_account_navigation'); ?>
,但似乎不显示从一无所有我放入函数的内容.php
有人可以帮我解决这个钩子有什么问题吗?
答
妍不需要在我的帐户模板进行任何更改(如你正在使用现有的钩)......为了让您的自定义内容显示,如果你需要做这样说:
add_action('woocommerce_after_account_navigation', 'custom_content_after_account_navigation');
function custom_content_after_account_navigation(){
$html = '<h3>Title</h3>';
$html.='<li><a href="link">Text1</a></li>';
$html.='<li><a href="link">Text2</a></li>';
echo $html;
}
代码在你的活动子主题(或主题)的function.php文件中,或者也在任何插件文件中。
在WooCommerce 3上测试并工作。
这个自定义内容将显示在我的帐户菜单
我插入了下面,但看到这个在我的帐户页面https://i.imgur.com/6Rznu4q.png?1 我使用Woocommerce 3.2.1 – DrMTR
@DrMTR当然,因为你有佣人一些其他的自定义...看到它在这个测试服务器(使用作为登录名/密码=>测试/测试):http://www.cbleu.net/sites/tie2 /我的帐户/ ...我也使用Woocommerce 3.2.1 ... – LoicTheAztec
是在您的服务器上工作好吧,我不知道我的不显示确定。 :( – DrMTR