Support

Account

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 @jzjzjzjzj,

    Thanks for the post.

    You will only need to call the ACF display function within the woo_new_product_tab_content() function.

    The code will look like so:

    add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
    function woo_new_product_tab( $tabs ) {
    	
    	// Adds the new tab
    	
    	$tabs['test_tab'] = array(
    		'title' 	=> __( 'Shipping', 'woocommerce' ),
    		'priority' 	=> 50,
    		'callback' 	=> 'woo_new_product_tab_content'
    	);
    
    	return $tabs;
    
    }
    function woo_new_product_tab_content() {
    
    	// The new tab content
    
    	echo '<h2>New Product Tab</h2>';
    	echo '<p>Here\'s your new product tab.</p>';
            echo get_field('fieldname', $post_id);
    	
    }