Home › Forums › Front-end Issues › Only Show Tabs if there's content? › Reply To: Only Show Tabs if there's content?
Am trying to do a similar thing – not sure if you figured it but I found the answer at bloke.com. Add to functions.php
I’m trying to take it a step further and want to display a repeater field in the tab and can’t figure it out. Any Woocommerce gurus out there that can help?
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
global $post, $product;
$ingredients = get_post_meta($post->ID, 'ingredients', TRUE);
// Adds the new tab
if (!empty($ingredients)) {
$tabs['test_tab'] = array(
'title' => __( 'Ingredients', 'woocommerce' ),
'priority' => 50,
'callback' => 'woo_new_product_tab_content'
);
}return $tabs;
}
function woo_new_product_tab_content() {
global $post, $product;
$ingredients = get_post_meta($post->ID, 'ingredients', TRUE);
echo($ingredients);
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.