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

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?

CODE HERE

<div class=”container”>
<?php
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>
</div>

‘;
}
}
}

echo ‘</ul>’;
echo ‘</div>’;

echo ‘<div class=”col-sm-8″>’;
//tab content
foreach ($customcontent as $showcontent) {
echo $showcontent ;
}
echo ‘</div>’;

echo ‘</div>’;

?>
</div>

Static Code Working Here

https://codepen.io/fdharsihexagon/full/wYepNv/

Read more here:: How do i get post content after the click of the each sub tab of the parent tab?

Leave a Reply

Your email address will not be published. Required fields are marked *