Remove_Action对我不起作用以删除主题的操作..?

发布于 2025-01-31 04:25:05 字数 577 浏览 3 评论 0原文

我正在运行WordPress + WooCommerce + Storefront。我正在尝试删除页脚中的“使用店面构建的”信用额度。

我看到大量文章解释如何通过使用remove_action使用如下:

remove_action('storefront_footer', 'storefront_credit',20);

这是不起作用的。我已经通过摘要插件尝试了一下,并且我在孩子主题中尝试了functions.php。

我还验证了自编写这些文章以来的主题代码中似乎没有任何更改,因此它具有相同的功能和挂钩名称。

我不确定我在这里缺少什么.. ??关于此信息的任何信息将不胜感激。谢谢!

I'm running WordPress + WooCommerce + Storefront. I'm trying to remove the "Built with Storefront & WooCommerce" credit in the footer.

I see lots of articles explaining how to do that by using remove_action as follows:

remove_action('storefront_footer', 'storefront_credit',20);

This is not working, though. I've tried it through a Snippets plugin, and I've tried it through the functions.php in my child theme.

I've also verified that nothing seems to have changed in the theme code since these articles were written, so it has the same function and hook names.

I'm not sure what I'm missing here..?? Any information on this would be greatly appreciated. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

腹黑女流氓 2025-02-07 04:25:06

为了删除操作,您必须一定要在添加之前将其删除。这是父主题的挂钩,因此,如果您从子主题或通过代码段中删除_ATCHACTION,那就为时已晚。

除非...您将其挂接到“ WP” WordPress操作中,除非您更早地进行删除。

尝试:

add_action( 'wp', 'bbloomer_remove_storefront_actions' );

function bbloomer_remove_storefront_actions() {
   remove_action( 'storefront_footer', 'storefront_credit', 20 );
}

您可以做的另一件事可以确保可以通过使用相同的钩子来删除操作,但是优先级:

add_action( 'storefront_footer', 'bbloomer_remove_storefront_actions', 19 );
    
function bbloomer_remove_storefront_actions() {
   remove_action( 'storefront_footer', 'storefront_credit', 20 );
}

在此示例中,我要删除“ storefront_credit”,它具有优先= 20具有优先级19的相同钩子,因此我在添加之前将其删除。

In order to remove the action you must be sure to remove it before it's added. This is a parent theme's hook, so if you remove_action from the child theme or via code Snippets, it's already too late.

Unless... you make the remove_action trigger earlier, by hooking that to "wp" WordPress action.

Try with:

add_action( 'wp', 'bbloomer_remove_storefront_actions' );

function bbloomer_remove_storefront_actions() {
   remove_action( 'storefront_footer', 'storefront_credit', 20 );
}

Another cool thing you can do to absolutely make sure you can remove an action is by using the same hook, but with a lower priority:

add_action( 'storefront_footer', 'bbloomer_remove_storefront_actions', 19 );
    
function bbloomer_remove_storefront_actions() {
   remove_action( 'storefront_footer', 'storefront_credit', 20 );
}

In this example, I'm removing 'storefront_credit' which has priority = 20 by hooking into the same hook, with priority 19, so that I remove it before it's added.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文