內容簡介
這個免費的 WooCommerce 外掛允許您在商店的主頁面上隱藏類別。
為此,您需要在 WooCommerce > 設置 > 產品選項標籤部分中使用“,”分隔的方式保存類別。
為了使其工作,您必須在主頁中顯示商品類別。這可以通過自訂器進行設置。外觀 > 自訂 > WooCommerce > 產品目錄。
“選擇在主商店頁面上顯示什麼。”請選擇如下屏幕截圖所示的顯示類別。
附加信息
對於有不同/自定義頁面的商店用戶,您可以編輯 wc-hide-categories.php 文件。
找到第127行,並刪除 //
//$mwd_opt4 = in_array( 'product_cat', $taxonomies ) && ! is_admin() && is_page('YOUR_PAGE_SLUG'),
然後找到第129行 /*|| $mwd_opt4*/
更改為
|| $mwd_opt4
要從這些類別中刪除產品,請找到第160行
// Uncomment the function below if you also want those products hidden
/*
add_action( 'woocommerce_product_query', 'mwd_hwcosp_remove_product_in_cat' );
function mwd_hwcosp_remove_product_in_cat( $q ) {
//hwcosp_global is the databse row entry
$opt_terms = get_option('hwcosp_global');
// Processes our users data to the way we want it from above
$data = mwd_hwcosp_comma_separated_to_array($opt_terms);
$tax_query = (array) $q->get('tax_query');
$tax_query[] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => $data, // Set Category Slug which products not show on the shop and Archieve page.
'operator' => 'NOT IN'
);
$q->set( 'tax_query', $tax_query );
}
*/
代碼有很好的文檔,因此易於找到所需部分。
如果您有任何問題,請在支援論壇中提問。謝謝。
外掛標籤
開發者團隊
② 後台搜尋「Hide Categories On Shop Page」→ 直接安裝(推薦)
原文外掛簡介
This free WooCommerce extension permits you to hide categories on your shops main page.
For this you have to save the categories with ‘,’ seperated in woocommerce > settings > products tab section.
In order for this to work you have to have Categories displayed. This can be set via Customizer. Appearance > Customize > WooCommerce > Product Catalog.
“Choose what to display on the main shop page.” Select Show categories as seen in the Screenshot below.
Additional Information
For users who has a different/custom page for their shop you can edit the wc-hide-categories.php file
Find line # 127 and remove //
//$mwd_opt4 = in_array( 'product_cat', $taxonomies ) && ! is_admin() && is_page('YOUR_PAGE_SLUG'),
Then find line #129 /*|| $mwd_opt4*/
Change to
|| $mwd_opt4
To remove products from those categories find line 160
// Uncomment the function below if you also want those products hidden
/*
add_action( 'woocommerce_product_query', 'mwd_hwcosp_remove_product_in_cat' );
function mwd_hwcosp_remove_product_in_cat( $q ) {
//hwcosp_global is the databse row entry
$opt_terms = get_option('hwcosp_global');
// Processes our users data to the way we want it from above
$data = mwd_hwcosp_comma_separated_to_array($opt_terms);
$tax_query = (array) $q->get('tax_query');
$tax_query[] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => $data, // Set Category Slug which products not show on the shop and Archieve page.
'operator' => 'NOT IN'
);
$q->set( 'tax_query', $tax_query );
}
*/
The code is well documented so its easy to find what part you are looking for
If you have any question please ask in the support forum, Thanks
