Product Archive

WooCommerce Add Product-Unique Content Below Loop Item Image

WooCommerce custom product field data displaying between image and title on loop item

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About This Solution

Showing product-specific content below the image on a loop item is really easy. In other words, if you want to show content, unique to each individual product below the product featured image on the product loop which appears on the product archive template among other places, this guide is for you. This solution creates you a custom product editor metabox to enter custom text, then displays it under the product image.

/**
 * Snippet Name:     WooCommerce Custom Product Metabox For Content Below Image On Loop Item
 * Snippet Author:   ecommercehints.com
*/

add_action ('woocommerce_product_options_advanced', 'ecommercehints_product_data_metabox');
function ecommercehints_product_data_metabox() {
   echo '<div class="options_group">';
   woocommerce_wp_text_input (array (
      'id'                => 'custom_loop_content_below_image',
      'value'             => get_post_meta (get_the_ID(), 'custom_loop_content_below_image', true),
      'label'             => 'Custom Loop Content',
      'description'       => 'Text to appear below loop image'
  ));
   echo '</div>';
}

add_action ('woocommerce_process_product_meta', 'ecommercehints_save_field_on_update', 10, 2);
function ecommercehints_save_field_on_update ($id, $post) {
      update_post_meta ($id, 'custom_loop_content_below_image', $_POST['custom_loop_content_below_image']);
}

add_action( 'woocommerce_shop_loop_item_title', 'ecommercehints_woocommerce_shop_loop_item_title', 1, 0 );
function ecommercehints_woocommerce_shop_loop_item_title() {
global $product;
$custom_loop_content_below_image = $product->get_meta ('custom_loop_content_below_image');
echo $custom_loop_content_below_image;
};

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 20% off on your first month with us.

26027
WELCOME OFFER