如何仅向 woocommerce 页面添加功能

发布于 2025-01-17 19:11:04 字数 440 浏览 2 评论 0原文

我有此代码来删除WooCommerce中的一部分面包屑,该代码在第二个面包屑中说“产品”:

if( $item_position === 2 ){continue;}

虽然它确实有效,但它也可以从其他页面中删除第二个面包屑,而我只希望它将其从中删除WooCommerce,所以我尝试了:

if ( is_woocommerce && $item_position === 2 ){continue;}

它与以前的情况相同,我也尝试过:

if (is_woocommerce ($item_position === 2 ){continue;}

现在可以在我的其他页面上使用,但将完全从WooCommerce中删除面包屑。 我只是在学习,我不知道我在做什么错。

I have this code I put in to remove part of my breadcrumbs in woocommerce which said "Products" in the second crumb:

if( $item_position === 2 ){continue;}

While it does work, it also removes the second breadcrumb from my other pages, while I just want it to remove it from woocommerce so I tried:

if ( is_woocommerce && $item_position === 2 ){continue;}

Which did the same as the previous, and I also tried:

if (is_woocommerce ($item_position === 2 ){continue;}

Which now works on my other pages but will completely remove breadcrumbs from woocommerce.
I'm just learning and I have no idea what i'm doing wrong.

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

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

发布评论

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

评论(1

陌若浮生 2025-01-24 19:11:04

is_woocommerce()是一个函数。

正确的语法是:

if (is_woocommerce() && $item_position === 2 ) { 
    continue; 
}

is_woocommerce() is a function.

The correct syntax is:

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