Home › Forums › Backend Issues (wp-admin) › Snippet for Custom Field to Display in Product Tab › Reply To: Snippet for Custom Field to Display in Product Tab
Hi James
In this case, how shall we hide that tab or remove that tab if get_field('fieldname', $post_id);
is empty.
Sorry to bother you, I found the solution:
//adding new tab//
add_filter( 'woocommerce_product_tabs', 'product_tab' );
function product_tab( $tabs ) {
if ( get_field('fieldname', $post_id) ) {
$tabs[] = array(
'title' => 'Specifications',
'priority' => 15,
'callback' => 'show_content'
);
}
return $tabs;
}
function show_content() {
$downloads = get_field('fieldname', $post_id);
if( $downloads ):
echo get_field('fieldname', $post_id);
endif;
}
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.