Last active
November 24, 2015 18:57
-
-
Save hemusyl/63e9829f4ee4c21e4676 to your computer and use it in GitHub Desktop.
Tab Dynamic (Bootsrap tab)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://wordpress.stackexchange.com/questions/192451/dynamic-bootstrap-tabs-with-post-title-doesnt-display-the-content?lq=1 | |
<div id="tab"> | |
<ul class="nav nav-tabs" role="tablist"> | |
<?php $loop = new WP_Query( array( 'post_type' => 'candidates', 'posts_per_page' => -1 ) ); ?> | |
<?php | |
$counter = 0; | |
while ( $loop->have_posts() ) : $loop->the_post(); | |
$counter++; | |
?> | |
<li role="presentation" class="post-<?php the_ID(); ?> <?=($counter == 1) ? 'active' : ''?>"><a href="#post-<?php the_ID(); ?>" aria-controls="home" role="tab" data-toggle="tab"><?php the_title();?></a></li> | |
<?php endwhile; wp_reset_query(); ?> | |
</ul> | |
<div class="tab-content"> | |
<?php | |
$counter = 0; | |
$loop = new WP_Query( array( 'post_type' => 'candidates', 'posts_per_page' => -1 ) ); | |
while ( $loop->have_posts() ) : $loop->the_post(); | |
$counter++; | |
?> | |
<div role="tabpanel" class="tab-pane <?=($counter == 1) ? 'active' : ''?>" id="post-<?php the_ID(); ?>"><?php the_content();?></div> | |
<?php endwhile; ?> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment