Answer the question
In order to leave comments, you need to log in
How to duplicate a tab?
I made category tabs, identified them, hung the active class
<?php
$i=1;
$cat = get_query_var('cat');
$categories = get_categories('parent='.$cat.'');
foreach ($categories as $category) { $i++; }
if ($i > 1) {
echo "<ul>";
foreach ($categories as $category) { ?>
<li data-id="<?php echo get_cat_ID( $category->name ); ?>"><?php echo $category->name; ?></li>
<?php }
echo "</ul>";
} else {
$pcat = get_category(get_query_var('cat'),false);
$pcatid = $pcat->category_parent;
$categories = get_categories('parent='.$pcatid.'');
echo "<ul>";
foreach ($categories as $category) { ?>
<li data-id="<?php echo get_cat_ID( $category->name ); ?>" <?php if ($category->term_id == $cat) { ?> class="active"<?php } ?>><?php echo $category->name; ?></li>
<?php }
echo "</ul>";
}
?>
<div class="tab_container" id="<?php echo get_cat_ID( $category->name ); ?>">
<h1>2</h1>
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question