I have the following code that works and need to Replace the existing category with AFC images
add_action('woocommerce_before_subcategory_title', 'wpse_add_custom_text_under_category_title', 10);
function wpse_add_custom_text_under_category_title($category) {
$term_id = 'product_cat_'.$category->term_id;
echo'<ol >';
for ( $i = 1; $i <= 3; $i ){
$category_image = '<img src="'.get_field('category_image_' . $i, $term_id).'"/>';
if( $category_image ) {
echo '<li id="carousel__slide" tabindex="0" >'.$category_image.'<div ></div></li>';
} else {
echo '';
}
}
echo'</ol>';
}
this scrolls but now the default images are in their place first screenshot of admin panel
frontend screenshot
how can I remove the default once
CodePudding user response:
Just remove default one
remove_action( 'woocommerce_before_subcategory_title', 'woocommerce_subcategory_thumbnail', 10 );
Add this in to your theme functions.php