Michael
Michael

Reputation: 11

woo commerce - how to show custom fields on published page

I have set 2 custom fields on the wordpress / woocommerce product page called "imballo" and "sottoimballo" with their values. How do I display these on the published page?

Thanks!

Upvotes: 0

Views: 1201

Answers (1)

Domain
Domain

Reputation: 11808

You would have to display the custom fields in the WooCommerce Single Product Page template,

You could do it in two ways,

  1. Add a code in an existing hook of the Product Single page. Check hooks here
  2. Modify the template by overriding it in your WordPress theme. Read here

And in the place where you want to display do the following,

<?php
     //Please add your HTML structure as needed.
     echo get_post_meta(get_the_ID(), 'imballo');
     echo get_post_meta(get_the_ID(), 'sottoimballo');
?>

Upvotes: 1

Related Questions