By default need to display 1st Tab

Question
<?php get_header(); ?>
<?php
$term_id = get_queried_object()->term_id;
$term = get_term($term_id);
$term_meta = get_term_meta($term->term_id);

$term_parent_id = $term->parent;
if($term_parent_id==0){ $term_parent_id = $term_id; }
$sub_terms = get_terms( array(
                    'taxonomy'  => 'our-service',
                    'parent'    => $term_parent_id,
                    'hide_empty'=> false,
                    'orderby'   => 'term_id',
                    'order'     => 'ASC',
                ) );
?>

 <section>
    <div class="serviceHead">
        <div class="container">
            <div class="row">
                <div class="col-sm-10 col-sm-offset-1">
                    <div class="serviceText">
                        <h2><?php echo $term->name; ?></h2>
                        <p><?php if(!empty($term_meta['wpcf-menu-content'][0])){ echo $term_meta['wpcf-menu-content'][0]; }else{ echo $term->description; } ?></p>
                        <ul>
                            <?php
                            $terms = get_terms( array(
                                                'taxonomy'  => 'our-service',
                                                'parent'    => 0,
                                                'hide_empty'=> false,
                                                'orderby'   => 'term_id',
                                                'order'     => 'ASC',
                                            ) );
                            
                            foreach ( $terms as $key => $s_term ) { ?> 
                                <li><a href="<?php echo get_term_link($s_term->term_id); ?>"><?php echo $s_term->name; ?></a></li>
                            <?php } ?>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<section>
    <div class="serviceDetails">
        <div class="container">
            <div class="col-sm-4">
                <div class="leftContent">
                    <ul class="nav nav-pills nav-stacked">
                        <?php
                        foreach($sub_terms as $key => $sub_term) { 
                            ?>
                            <li class="<?php echo $active; ?>"><a  href="#<?php echo $sub_term->slug ?>"><?php echo $sub_term->name; ?></a></li>
                        <?php }    
                        ?>
                    </ul>
                </div>
            </div>
            
            <div class="col-sm-8">
                <div class="rightContent">
                    <div class="tab-content">
                        
                        <?php
                        foreach($sub_terms as $js_key => $js_sub_term) { 
                            if( $js_sub_term->term_id == $term_id ){ $js_active = "active"; } else { if($js_key==0 && $term->parent==0){ $js_active = "active"; } else { $js_active = ""; } }
                            $js_term_meta = get_term_meta($js_sub_term->term_id);
                            
                            ?>
                            <div id="<?php echo $js_sub_term->slug ?>" class="tab-pane fade in <?php echo $js_active; ?>">
                                <h3><?php echo $js_sub_term->name; ?></h3>
                                <?php echo wpautop($js_sub_term->description); ?>
                            </div>
                        <?php }    
                        ?>    
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<?php get_footer(); ?>
0
Zain 1 year 2020-07-15T09:12:14-05:00 0 Answers 62 views 0

Leave an answer

Browse
Browse