1
我在添加「相關產品」到選項卡並使其適用於使用短代碼的帖子時遇到問題。這裏是一個的被放置在我的functions.php將「相關產品」添加到WooCommerce的自定義選項卡中
[product_page ID =「99」]
在這裏,短代碼和完整的代碼是我在用我的主題代碼的functions.php
remove_action('woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
/*
* Register custom tab
*/
function woo_custom_product_tab($tabs) {
$custom_tab = array(
'custom_tab' => array(
'title' => __('Custom Tab','woocommerce'),
'priority' => 9,
'callback' => 'woo_custom_product_tab_content'
)
);
return array_merge($custom_tab, $tabs);
}
/*
* Place content in custom tab (related products in this sample)
*/
function woo_custom_product_tab_content() {
woocommerce_related_products();
}
add_filter('woocommerce_product_tabs', 'woo_custom_product_tab');
下面是我收到的錯誤:
Fatal error: Call to a member function get_upsells() on a non-object in public_html/wp-content/plugins/woocommerce/templates/single-product/up-sells.php on line 25
這工作!然而,這只是與短代碼一起工作,但不適用於woocommerce頁面......任何解決方案? – SlyMurphy