Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

93
Vistas
How to add tab "ALL" to menu tab dynamically

I have a dynamic tab list, I wanted to add a tab "All" The click of tab 3all" display all pots

For this code, it only shows dynamic tab, so, I am looking for a solution to add a tab "All"

I tried some solution but I did not arrive

The idea it'is to add atatic tab "All"

 <?php
    echo '<ul class="nav nav-tabs" role="tablist">';
    $args = array(
        'taxonomy' => 'annualreports_category',
        'hide_empty'=>0,
        'orderby' => 'name',
        'order' => 'ASC'
    );
    $categories = get_categories($args);
    foreach($categories as $category) { 
        echo 
            '<li>
                <span data-href="'.$category->slug.'" role="tab" data-toggle="tab">    
                    '.$category->name.'
                </span>
            </li>';
    }
    echo '</ul>';
    
    echo '<div class="investors-content">';
    foreach($categories as $category) { 
        echo '<div class="tab-pane" id="' . $category->slug.'">';
        $catslug = $category->slug;
        $the_query = new WP_Query(array(
            'post_type' => 'annualreports_post',
            'posts_per_page' => -1,
            'tax_query' => array(
                            array(
                                'taxonomy' => 'annualreports_category',
                                'field'    => 'slug',
                                'terms'    => array( $catslug ),
                                'operator' => 'IN'
                            ),
                        ),
        ));                 
        while ( $the_query->have_posts() ) : 
        $the_query->the_post();
            echo '<h1>';
            the_title();
            echo '</h1>';
        endwhile; 
        echo '</div>';
    } 
    echo '</div>';
    ?>

<script>

$(".investors-content .tab-pane").each(function(){
    $(this).hide();
    $('.investors-content .tab-pane:first-child()').show();
});

$('.nav-tabs li>span').on( "click", function(e) {
    e.preventDefault();
    var id = $(this).attr('data-href');
    $(".investors-content .tab-pane").each(function(){
        $(this).hide();
        if($(this).attr('id') == id) {
            $(this).show();
        }
    });
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Check this working example similar to your requirement

$('#tabAll').on('click',function(){
  $('#tabAll').parent().addClass('active');  
  $('.tab-pane').addClass('active in');  
  $('[data-toggle="tab"]').parent().removeClass('active');
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
  
  <div class="container">
  <h2>Dynamic Tabs</h2>
  <p>To make the tabs toggleable, add the data-toggle="tab" attribute to each link. Then add a .tab-pane class with a unique ID for every tab and wrap them inside a div element with class .tab-content.</p>

  <ul class="nav nav-tabs">
  <li><a id="tabAll" href="#">All</a></li>
    <li class="active"><a data-toggle="tab" href="#home">Home</a></li>
    <li><a data-toggle="tab" href="#menu1">Menu 1</a></li>
  </ul>

  <div class="tab-content">
    <div id="home" class="tab-pane fade in active">
      <h3>HOME</h3>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
    <div id="menu1" class="tab-pane fade">
      <h3>Menu 1</h3>
      <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
    </div>
  </div>
</div>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda