Код: Выделить всё
/* Adding top-level product category */
add_action('woodmart_after_header', 'show_top_level_categories', 30);
function show_top_level_categories() {
// We exclude the cart, checkout, and thank you pages
if (is_cart() || is_checkout() || is_order_received_page()) return;
global $wp_query;
// We get the ID of the current category
$current_category_id = isset($wp_query->queried_object->term_id) ? $wp_query->queried_object->term_id : null;
// Getting top-level product categories
$categories = get_terms([
'taxonomy' => 'product_cat',
'parent' => 0,
'hide_empty'=> true,
'orderby' => 'menu_order',
'order' => 'ASC'
]);
if (!empty($categories)): ?>
[list]
[*]term_id === $current_category_id) ? 'class="active"' : ''; ?>>
[url=">[/url]
[/list]
Подробнее здесь: [url]https://stackoverflow.com/questions/79897768/show-top-level-product-categories-on-specific-woocommerce-pages[/url]