WooCommerce Display Product-Unique Content On Loop Items

WooCommerce custom metabox field data showing on product loop


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

This guide shows you how you can display product-specific content on the loop items which are shown on the product archive page. You may wish to show an offer you are running or the billing cycle for a particular product. This guide shows you how to create a product metabox to enter unique content then display it on the loop above the add to cart button

 * Snippet Name:     WooCommerce Custom Product Data Metabox For Custom Loop Item Text
 * 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',
      'value'             => get_post_meta (get_the_ID(), 'custom_loop_content', true),
      'label'             => 'Custom Loop Content',
	  'desc_tip'		  => true,
      'description'       => 'Text to appear on the product loop item'
   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', $_POST['custom_loop_content']);

add_action( 'woocommerce_after_shop_loop_item', 'ecommercehints_woocommerce_after_shop_loop_item', 1, 0 );
function ecommercehints_woocommerce_after_shop_loop_item() {
global $product;
$custom_loop_content = $product->get_meta ('custom_loop_content');
echo $custom_loop_content . '<br><br>';

Snippet Benefits

  • Let customers know of a special offer you are running for a particular product.
  • Show literally any product-specific content you like from a higher level category page on the loop items.
WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

Your email address will not be published. Required fields are marked *

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers