【发布时间】:2018-09-20 14:22:42
【问题描述】:
我发现在 WooCommerce (WC) 中我可以直接编辑以获得我想要的结果,即编辑以下函数:https://github.com/woocommerce/woocommerce/blob/master/includes/class-wc-breadcrumb.php#L222
private function add_crumbs_product_tag() {
$current_term = $GLOBALS['wp_query']->get_queried_object();
$this->prepend_shop_page();
/* translators: %s: product tag */
$this->add_crumb( sprintf( __( 'My Edit: %s', 'woocommerce' ), $current_term->name ), get_term_link( $current_term, 'product_tag' ) );
}
现在我知道直接编辑 WC 插件是不好的做法,所以我正在寻找一种替代方法,这样当 WC 更新时,更改不会被覆盖。
覆盖尝试
我尝试将我编辑的类添加到我的子主题 (mytheme-child/woocommerce/includes/class-wc-breadcrumb.php),但这似乎不起作用。
我能做什么?
【问题讨论】:
-
嘿,我真的会推荐这个文档:iandunn.name/2014/01/10/… 无论如何我都会用钩子来做;)
标签: php wordpress woocommerce breadcrumbs custom-taxonomy