I need to add custom tab on product page, but i want it show it only for some product ids.
Here my code for adding the custom tab on front end.
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
$tabs['desc_tab'] = array(
'title' => __( 'Additional Information', 'woocommerce' ),
'priority' => 50,
'callback' => 'woo_new_product_tab_content'
);
return $tabs;
}
and then i should add below function too for displaying the content.
function woo_new_product_tab_content() {
echo '<p>some text</p>';
}
but now these function work for all product ids. I want to load this two function only for some product id, could someone help me?
I tired to add if(is_product() && get_the_id() == 8)
on both functions but $tabs
not appear on others product ids page , ( on product id "8" $tabs
worked well )