wordpress - ACF plugin relationship field, if no value in nav tab,want to hide the tab -
i using bootstrap nav tab , acf custom field in wp theme. want hide nav tab if there no value in relation. how that? below code-- want hide compatible tab, if relation dont return value
<!-- nav tabs --> <ul class="nav nav-tabs nav-justified" role="tablist"> <li role="presentation" class="active"><a href="#home" aria-controls="overview" role="tab" data-toggle="tab">overview</a></li> <li role="presentation"><a href="#compatibility" aria-controls="compatibility" role="tab" data-toggle="tab"> compatibility </a></li> <li role="presentation"><a href="#datasheet" aria-controls="datasheet" role="tab" data-toggle="tab">datasheet</a></li> <li role="presentation"><a href="#order" aria-controls="order" role="tab" data-toggle="tab">order</a></li> </ul> <!-- tab panes --> <div class="tab-content"> <div role="tabpanel" class="tab-pane fade in active" id="home"> <div role="tabpanel" class="tab-pane fade" id="compatibility"> <?php $posts = get_field('compatible_with'); if( $posts ): ?> <ul> <?php foreach( $posts $p ): // variable must not called $post (important) ?> <li> <a href="<?php echo get_permalink( $p->id ); ?>" rel="</a> <a href="<?php echo get_permalink( $p->id ); ?>"><?php echo get_the_title( $p->id ); ?></a> </li> <?php endforeach; ?> </ul> <?php endif; ?> </div> <div role="tabpanel" class="tab-pane fade" id="datasheet"></div> <div role="tabpanel" class="tab-pane fade" id="order"></div> </div> </div> </div> </div> </div>
i want use function
if( count( get_field('compatible_with') ) > 0 ) :
any ways using these 2 lines of code, sorted out problem
<?php if( get_field('compatible_with') ): ?> <li role="presentation"><a href="#compatibility" aria-controls="compatibility" role="tab" data-toggle="tab"> compatibility </a></li> <?php endif; ?>
Comments
Post a Comment