';
} else {
echo 'No categories found.';
}
// Ensure the right query to load products for the category
if (is_tax('category')) { // Check if we are on a category archive page
$term = get_queried_object();
$args = array(
'post_type' => 'product',
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'id',
'terms' => $term->term_id,
'operator' => 'IN',
),
),
);
$query = new WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
// Display product info here
the_title('
', '
');
the_content();
}
wp_reset_postdata();
} else {
echo 'No products found in this category.';
}
}
return ob_get_clean(); // Return the buffered content
});
Localization systems/ System solutions/ SICK - TecTesla Industrial Solutions