WordPress.org

Support

Support » Plugins and Hacks » get_post_meta – woocomerce products

get_post_meta – woocomerce products

  • damian.smith
    Participant

    @damiansmith

    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>'; ?>
    
    <p>
    <?php echo get_post_meta($post->ID, 'rel_cat', true); ?>
    </p>
    
    <?php
     echo '</div>';
    }

    http://wordpress.org/extend/plugins/woocommerce/

Viewing 1 replies (of 1 total)
  • bheadrick
    Participant

    @bheadrick

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

    global $post;

Viewing 1 replies (of 1 total)
  • The topic ‘get_post_meta – woocomerce products’ is closed to new replies.