How to check parent & child category

On your category template you can use get_queried_object() to get the current WP_Term object. From that you can check the parent property, which is 0, if it is a parent, or some integer, if it is a child term as it returns the parent term’s ID. $current_term = get_queried_object(); if ( $current_term->parent ) { // … Read more

Add filter for specific category only

Went about it a different way, works OK. Just in case anyone else is looking for similar functionality; //* dropdown add_filter( ‘woocommerce_product_categories_widget_dropdown_args’, ‘woo_product_cat_widget_args’ ); //* list add_filter( ‘woocommerce_product_categories_widget_args’, ‘woo_product_cat_widget_args’ ); function woo_product_cat_widget_args( $cat_args ) { if ( is_product_category( ‘experiences’ ) || term_is_ancestor_of( 2921, get_queried_object_id(), ‘product_cat’ ) ) { $cat_args[‘exclude’] = array(2548, 2245, 2775, 2913, 2846); … Read more

Order wp_dropdown_categories by ASC or DESC

Hopefully your syntax was correct when you placed order and orderby. In thoery, your code should work with the following wp_dropdown_categories( array( ‘show_option_none’ => $cat_text, ‘option_none_value’ => ”, ‘taxonomy’ => rtcl()->category, ‘name’ => ‘rtcl_category’, ‘id’ => ‘rtcl-category-search-‘ . wp_rand(), ‘class’ => ‘form-control rtcl-category-search’, ‘selected’ => get_query_var( ‘rtcl_category’ ), ‘hierarchical’ => true, ‘value_field’ => ‘slug’, ‘depth’ … Read more