我在WooCommerce单一产品页面中有定制的选项卡,这些选项卡链接到来自自定义帖子类型的ACF条目。这很完美。但是我只希望选项卡显示是否有附加的帖子。
if( get_field('author') ):
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
// Adds the new tab
$tabs['author_tab'] = array(
'title' => __( 'Authors', 'woocommerce' ),
'priority' => 50,
'callback' => 'woo_new_product_tab_content'
);
return $tabs;
}
endif;
/* New Speakers Tab Content */
function woo_new_speaker_tab_content() {
// The new tab content
echo '<h2>Speakers</h2>';
$speakersnames=list_speakers();
}
/* Call Product Authors */
function list_ffpauthors() {
$post_objects = get_field('author');
if( $post_objects ):
echo '<ul class="authorgrid">';
foreach( $post_objects as $post):
setup_postdata($post);
echo '<li class="authorbox"><div class="socialimage"><a href="'.
get_permalink($post->ID) .'"> '.get_the_post_thumbnail($post->ID, $size =
'portrait').'</a></div><a href="'. get_permalink($post->ID) .'">'.
get_the_title($post->ID) .'</a></li>';
endforeach;
echo '</ul>';
wp_reset_postdata();
endif;
}
例如如果ACF“作者”已分配了一些作者,则显示选项卡“ author_tab” 而我的演讲者也一样
希望对我的代码进行简单的调整即可解决此问题,因为我当前的代码只是在所有实例中都隐藏了标签。