'product’,
'posts_per_page’ => -1,
'fields’ => 'ids’, // Only retrieve product IDs to improve performance
);
// Check if on a product category page and get the category
if ( is_product_category() ) {
$category = get_queried_object();
if ($category && !empty($category->term_id)) {
// If category object is valid and has an ID, modify the query to filter by this category
$args[’tax_query’] = array(
array(
'taxonomy’ => 'product_cat’,
'field’ => 'term_id’,
'terms’ => $category->term_id,
),
);
} else {
// If no valid category, return (can also handle error or do nothing)
return; // Stop execution to prevent further errors
}
}
// Run the query
$query = new WP_Query($args);
// Output the product count
if ( is_product_category() && isset($category) ) {
echo $query->found_posts; // Number of products in this category
} elseif ( is_shop() ) {
echo $query->found_posts; // Total number of products in the shop
}
}
?>
pozycji
Miesiąc: marzec 2024
Header_filters-garden
Przycisk filtry + ilość wybranych pozycji
'product',
'posts_per_page' => -1,
'fields' => 'ids', // Only retrieve product IDs to improve performance
);
// Check if on a product category page and get the category
if ( is_product_category() ) {
$category = get_queried_object();
if ($category && !empty($category->term_id)) {
// If category object is valid and has an ID, modify the query to filter by this category
$args['tax_query'] = array(
array(
'taxonomy' => 'product_cat',
'field' => 'term_id',
'terms' => $category->term_id,
),
);
} else {
// If no valid category, return (can also handle error or do nothing)
return; // Stop execution to prevent further errors
}
}
// Run the query
$query = new WP_Query($args);
// Output the product count
if ( is_product_category() && isset($category) ) {
echo $query->found_posts; // Number of products in this category
} elseif ( is_shop() ) {
echo $query->found_posts; // Total number of products in the shop
}
}
?>
pozycji
filters_mobile-garden-raw
Filtry

Gotowe kompozycje

Kwiaty balkonowe i rabatowe

Pnące
(72)
Stojące i rabatowe
(43)
Zwisające
(27)
Owoce, warzywa i zioła

Przyjazne dla pszczół

Rośliny wg. stanowiska

Rośliny wieloletnie, drzewa, trawy

Rośliny domowe

Rośliny w koszach do powieszenia

Nowości

Promocje

Filters_mobile-garden
Wysuwane od dołu filtry, widoczne na szerokości ekranów od 992px
Filtry

Gotowe kompozycje

Kwiaty balkonowe i rabatowe

Pnące
(72)
Stojące i rabatowe
(43)
Zwisające
(27)
Owoce, warzywa i zioła

Przyjazne dla pszczół

Rośliny wg. stanowiska

Rośliny wieloletnie, drzewa, trawy

Rośliny domowe

Rośliny w koszach do powieszenia

Nowości

Promocje

Filters-archive-data
Filtry

’;
foreach ( $product_categories as $key => $category ) {
// Unique IDs for accordion controls
$headingId = „heading” . $category->term_id;
$collapseId = „collapse” . $category->term_id;
// Start accordion item
echo ’
’; // .accordion
} else {
echo 'No product categories found.’;
}
}
?>
’;
echo ’
’; // .accordion-item
}
echo ’’; echo ’’; echo ’
’; echo ’’;
echo ’
’; // .accordion-collapse
echo ’’;
// Get child categories
$child_args = array(
'taxonomy’ => 'product_cat’,
'orderby’ => 'name’,
'order’ => 'ASC’,
'hide_empty’ => false,
'parent’ => $category->term_id // Get direct children
);
$child_categories = get_terms( $child_args );
if ( !empty( $child_categories ) ) {
echo ’
’; // .accordion-body
echo ’ ’;
} else {
echo 'No child categories found.’;
}
// Close accordion item
echo ’Filters–archive–data-documentation
Footer–data-documentation
Filtry

No child categories found.