The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

get_post_meta - woocomerce products (2 posts)

  1. damian.smith
    Posted 3 years ago #

    Hey guys! I have the below code in my themes functions.php which creates a new tab on the product page.

    The only issue is, is that the get_post_meta is not working. I have added it to the products custom fields and this code normally works on standard wordpress posts. But not with a woocommerce post/product.

    Any ideas? :(

    add_action( 'woocommerce_product_tabs', 'sb_woocommerce_new_tab', 40 );
    add_action( 'woocommerce_product_tab_panels', 'sb_woocommerce_new_panel', 40 );
    function sb_woocommerce_new_tab() {
     echo '<li><a href="#tab-new">' . __('Technical Documents', 'woocommerce') . '</a></li>';
    function sb_woocommerce_new_panel() {
     echo '<div class="panel" id="tab-new">
     <h2>Technical Docs</h2>'; ?>
    <?php echo get_post_meta($post->ID, 'rel_cat', true); ?>
     echo '</div>';


  2. bheadrick
    Posted 3 years ago #

    you probably need to add this at the top of your sb_woocommerce_new_panel function:

    global $post;

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.