Created
December 16, 2016 18:22
-
-
Save TANVIRFAZLEY/4e3e2bc36a72b789576e04beecc225d8 to your computer and use it in GitHub Desktop.
Tab dynamic in wordpress
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
/*DEMO*/ | |
<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> | |
/****************************************MY CODE**********************************************************/ | |
<div class="col-xs-12 col-sm-8 wow fadeInDown"> | |
<div class="tab-wrap"> | |
<div class="media"> | |
<div class="parrent pull-left"> | |
<ul class="nav nav-tabs nav-stacked"> | |
<?php $loop = new WP_Query( array( 'post_type' => 'tab', 'posts_per_page' => 5 ) ); ?> | |
<?php | |
$counter = 0; | |
while ( $loop->have_posts() ) : $loop->the_post(); | |
$counter++; | |
?> | |
<li class="<?=($counter == 1) ? 'active' : ''?>"><a href="#tab<?php the_ID(); ?>" data-toggle="tab"><?php the_title();?></a></li> | |
<?php endwhile; wp_reset_query(); ?> | |
</ul> | |
</div> | |
<div class="parrent media-body"> | |
<div class="tab-content"> | |
<?php | |
$counter = 0; | |
$tab_heading_name = get_post_meta($post->ID, '_corlate_tab-name', true); | |
$loop = new WP_Query( array( 'post_type' => 'tab', 'posts_per_page' => 5 ) ); | |
while ( $loop->have_posts() ) : $loop->the_post(); | |
$counter++; | |
?> | |
<div class="tab-pane fade <?=($counter == 1) ? 'active in' : ''?>" id="tab<?php the_ID(); ?>"> | |
<div class="media"> | |
<?php if(has_post_thumbnail()):?> | |
<div class="pull-left"> | |
<?php the_post_thumbnail('tab_thumb', array('class' => 'img-responsive')); ?> | |
</div> | |
<?php endif;?> | |
<div class="media-body"> | |
<?php if($tab_heading_name):?> | |
<h2><?php echo $tab_heading_name; ?></h2> | |
<?php endif;?> | |
<?php the_content();?> | |
</div> | |
</div> | |
</div> | |
<?php endwhile; ?> | |
</div> <!--/.tab-content--> | |
</div> <!--/.media-body--> | |
</div> <!--/.media--> | |
</div><!--/.tab-wrap--> | |
</div><!--/.col-sm-6--> | |
please provide the frontend part
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
vai aktu help lagbe korben?
tab option ta bujtesina