Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Bradley-D/9479200 to your computer and use it in GitHub Desktop.
Save Bradley-D/9479200 to your computer and use it in GitHub Desktop.
// Add the div to wrap the image on the archive pages
add_action( 'woocommerce_before_shop_loop_item_title', create_function('', 'echo "<div class=\"archive-img-wrap\">";'), 5, 2);
add_action( 'woocommerce_before_shop_loop_item_title',create_function('', 'echo "</div>";'), 12, 2);
// If there is sub categories on the archive page add a wrap around their images as well
add_action( 'woocommerce_before_subcategory_title', create_function( '', 'echo "<div class=\"sub-archive-img-wrapper\">";'), 5, 2 );
add_action( 'woocommerce_before_subcategory_title', create_function( '', 'echo "</div>";' ), 12, 2 );
@B4rT26
Copy link

B4rT26 commented Oct 25, 2018

Unfortunately, create_function is deprecated in php 7.2, any idea how to replace this part? Thanks a lot :)

@de-b
Copy link

de-b commented Dec 19, 2018

function addWrapper() {
  echo "<div class=\"imagewrapper\">";  
}
add_action( 'woocommerce_before_shop_loop_item_title', 'addWrapper', 5, 2 );

// Add the div to wrap the image on the archive pages
function closeWrapper(){
  echo "</div>";
}
add_action( 'woocommerce_before_shop_loop_item_title', 'closeWrapper', 12, 2 );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment