Answer the question
In order to leave comments, you need to log in
How to display each category level in a taxonomy on a separate page?
<?php
$parents = get_terms('cat_catalog', [
'hide_empty' => false,
'parent' => 0,
]);
foreach ($parents as $parent) {
$term_link = get_term_link($parent,$taxonomy = 'cat_catalog');
?>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
<a href="<?php echo $term_link; ?>">
<div class="catalog-box">
<?php if($imgcat1=get_field("imgcat1",get_category($parent))){?>
<img src="<?php echo $imgcat1;?>"/>
<?php }?>
<p><?php echo $parent->name; ?></p>
</div>
</a>
</div>
<?php
}
?>
<?php
$taxonomy = get_terms('cat_catalog', [
'hide_empty' => false,
'parent' => 0,
]);
foreach ($taxonomy as $taxonomys) {
$terms = get_terms('cat_catalog', [
'hide_empty' => false,
'orderby' => 'parent',
'hierarchical' => true,
'child_of' => $taxonomys->term_id,
]);
foreach ($terms as $term) {
echo "<a href='".get_category_link( $term->term_id )."'>".$term->name."</a>";
}
}
?>
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