Home / Adding a Custom Field for Products (snippet 5)
Duplicate Snippet

Embed Snippet on Your Site

Adding a Custom Field for Products (snippet 5)

This code will display the values on the single product page. Add this code to your theme’s functions.php file:

Code Preview
php
<?php
add_action('woocommerce_product_meta_start', 'wcv_ingredients', 2);
function wcv_ingredients() {
    $output = get_post_meta( get_the_ID(), 'wcv_custom_product_ingredients', true ); // Change wcv_custom_product_ingredients to your meta key
    echo 'Ingredients: ' . $output . '';
}

Comments

Add a Comment