A
A
Andrey Nikiforov2018-02-10 04:21:59
WordPress
Andrey Nikiforov, 2018-02-10 04:21:59

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>";
}
?>

I have let's say 3 categories and actually how to display content from them? How to multiply the number of divs I need and make it work?
<div class="tab_container" id="<?php echo get_cat_ID( $category->name ); ?>">
                    <h1>2</h1>
                </div>

How to decide gentlemen

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question