Home Forums General Issues Adding WooCommerce tabs Reply To: Adding WooCommerce tabs

  • So it turns out that all fields show up if I make sure the “key” is different.

    But now I need to show my tabs, and this code, which should display the new tabs, does not (even when I ensure a tab has content in it):

    if (class_exists('acf') && class_exists('WooCommerce')) {
    	add_filter('woocommerce_product_tabs', function($tabs) {
    		global $post, $product;  // Access to the current product or post
    		$custom_tab_title = get_field('tab_title', $post->ID);
    		if (!empty($custom_tab_title)) {
    			$tabs['awp-' . sanitize_title($custom_tab_title)] = [
    				'title' => $custom_tab_title,
    				'callback' => 'awp_custom_woocommerce_tabs',
    				'priority' => 10
    		return $tabs;
    	function awp_custom_woocommerce_tabs($key, $tab) {
    		global $post;
    		?><h2><?php echo $tab['title']; ?></h2><?php
    		$custom_tab_contents = get_field('tab_contents', $post->ID);
    		echo $custom_tab_contents;

    Any advice is much appreciated!