Hide product categories and taxonomy terms in menu if empty

Not sure about the custom taxonomy, however I have used this code before to remove empty categories. You can add it to functions.php. add_filter( ‘wp_get_nav_menu_items’, ‘nav_remove_empty_category_menu_item’, 10, 3 ); function nav_remove_empty_category_menu_item ( $items, $menu, $args ) { global $wpdb; $nopost = $wpdb->get_col( “SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE count = 0” ); foreach ( $items as … Read more

WP_Query tax query part of slug

You can use below code to search in taxonomy. First using name__like in get_terms it will return all terms ids which have $keyword then that ids use in wp_query. $termIds = get_terms([ ‘name__like’ => $keyword, ‘fields’ => ‘ids’ ]); $args = [ ‘post_type’ => ‘movies’, ‘tax_query’ => [ [ ‘taxonomy’ => ‘actors’, ‘field’ => ‘id’, … Read more