הסרת קטגוריות מהווידג'ט של ווקומרס

כדי להסיר קטגוריות מהווידג'ט של ווקומרס, יש לשים קוד קצר בקובץ functions.php של התבנית.
חשוב! עריכה של קבצי מקור של התבנית צריכה להיות לאחר וידוא שיש גיבוי, כי טעות אחת קטנה יכולה לגרום לאתר לא לעלות.
כמו כן, לוודא שכל שינוי כזה מתועד בקובץ TXT בתיקיית ה-Programming של הלקוח.

/**
 * Remove Categories from WooCommerce Product Category Widget
 */
 
//* Used when the widget is displayed as a dropdown
add_filter( 'woocommerce_product_categories_widget_dropdown_args', 'rv_exclude_wc_widget_categories' );
//* Used when the widget is displayed as a list
add_filter( 'woocommerce_product_categories_widget_args', 'rv_exclude_wc_widget_categories' );
function rv_exclude_wc_widget_categories( $cat_args ) {
 $cat_args['exclude'] = array('42','62','64','65','63'); // Insert the product category IDs you wish to exclude
 return $cat_args;
}

כאשר יש להכניס את הקטגוריות שיש להסתיר בתוך המערך.

רפרנס: https://www.engagewp.com/remove-categories-woocommerce-product-category-widget/

 

x
סייען נגישות