I am displaying some custom fields on the woocommerce single product page with this
add_action( 'woocommerce_single_product_summary','add_custom_field', 20 );
function add_custom_field() {
global $post;
echo get_post_meta( $post->ID, 'Brand', true );
echo get_post_meta( $post->ID, 'Content', true );
return true;
}
This dispays only the values of the custom fields, but I would like the names before so it would look like this:
Brand: …
Content: …
The custom fields don’t aplly to every product though, so for the products where the custom fields are not set, nothing should be displayed.
Use this:
Try below code