admin管理员组

文章数量:1313347

I have a custom field such as "_additional_description", I need to display it at the end of the product description, but only if the product is simple.

Thank you for your help

I have a custom field such as "_additional_description", I need to display it at the end of the product description, but only if the product is simple.

Thank you for your help

Share Improve this question asked Dec 5, 2020 at 11:26 Tomáš SpisarTomáš Spisar 1
Add a comment  | 

1 Answer 1

Reset to default 0

You can take the help of hooks WooCommerce provides. Here is the link to the visual hook guide https://www.businessbloomer/woocommerce-visual-hook-guide-single-product-page/

Here is the code that suits your need.

add_action( 'woocommerce_after_single_product_summary', function() {
    global $product;

    if ( $product->is_type( 'simple' ) ) {
        get_post_meta( get_the_ID(), '_additional_description' );
    }
} );

I hope it helps.

本文标签: postsHow to display custom field in product description