For anyone else who needs to do the same, here is the full code I placed inside the child theme’s functions.php:
remove_action( 'woocommerce_before_shop_loop_item', 'x_woocommerce_before_shop_loop_item', 10 );
remove_action( 'woocommerce_after_shop_loop_item', 'x_woocommerce_after_shop_loop_item', 10 );
remove_action( 'woocommerce_before_shop_loop_item_title', 'x_woocommerce_before_shop_loop_item_title', 10 );
remove_action( 'woocommerce_after_shop_loop_item_title', 'x_woocommerce_after_shop_loop_item_title', 10 );
function my_woocommerce_before_shop_loop_item() {
echo '<div class="entry-product">';
}
function my_woocommerce_after_shop_loop_item() {
echo '</div>';
}
function my_woocommerce_before_shop_loop_item_title() {
echo '<div class="entry-wrap" style="padding: 0;"><header class="entry-header">';
}
function my_woocommerce_after_shop_loop_item_title() {
//woocommerce_template_loop_add_to_cart();
echo '</header></div>';
}
add_action( 'woocommerce_before_shop_loop_item', 'my_woocommerce_before_shop_loop_item', 10 );
add_action( 'woocommerce_after_shop_loop_item', 'my_woocommerce_after_shop_loop_item', 10 );
add_action( 'woocommerce_before_shop_loop_item_title', 'my_woocommerce_before_shop_loop_item_title', 10 );
add_action( 'woocommerce_after_shop_loop_item_title', 'my_woocommerce_after_shop_loop_item_title', 10 );
Due to the way Woocommerce hooks these functions, I found myself having to unhook more than the one function (it caused major formatting problems) and then add some inline CSS into my_woocommerce_before_shop_loop_item_title
as shown above (15px of padding was being loaded from another stylesheet that I didn’t have time to mess around with).
To show the changes above, I have commented out the woocommerce_template_loop_add_to_cart
function that is called inside my_woocommerce_after_shop_loop_item_title
(just an edited version of the original x_woocommerce_after_shop_loop_item_title
) which can actually just be deleted.