How do i get post content after the click of the each sub tab of the parent tab?

by Farhan Dharsi   Last Updated October 11, 2018 19:08 PM - source

I'm working on the custom template in this page I have added the JQery Tab in the, now how do I get content of each sub tab after click on it?

I have created Custom Post Type in the admin panel using Custom Post Types and Custom Fields creator – WCK, I have got Parent Tab and Sub tab, unable to show content according to the sub tab id?

Problem is that all posts content are showing after click on the single sub-tab?


    <div class="container">
       echo ' <div class="row">';
       echo '<div class="col-sm-3">';
       echo '<ul class="nav nav-tabs tabs-left" role="tablist">';
       $terms = get_terms('resourcecategories');

       if ( !empty( $terms ) && !is_wp_error( $terms ) ){

       //parent tab name  
       foreach ( $terms as $term ) {
       echo "<li class='active'><span>" . $term->name . "</span></li>";

       $args = array(
      'post_type' => 'resourceverticaltabs',
      'orderby' => 'title',
      'order' => 'ASC',
      'hierarchical' => false,
      'resourcecategories' => $term->slug

      //sub tab name          
      $displayparentandsub = get_posts($args);

      foreach ($displayparentandsub as $dpns) {
      echo ' <li role="presentation"><a href="#'.$dpns->ID.'" aria-controls="'.$dpns->ID.'" role="tab" data-toggle="tab">'.$dpns->post_title.'</a></li>';

      //tab content
      $customcontent[] ='

      <div class="tab-content">
      <div role="tabpanel" class="tab-pane" id="'.$dpns->ID.'">'.$dpns->post_content.'</div>


      echo '</ul>';
      echo '</div>';

      echo '<div class="col-sm-8">';
      //tab content 
      foreach ($customcontent as $showcontent) {
      echo $showcontent ;
      echo '</div>';

      echo '</div>';


Static Code Working Here

Related Questions

Custom slugs for Each Tab

Updated June 09, 2019 16:08 PM