List all Category
Thu Jul 06 2023 11:27:46 GMT+0000 (Coordinated Universal Time)
Saved by
@gshailesh27
//Put in header
<?php
global $post;
$category = get_queried_object();
?>
//Put where you want to display the list
<?php
$args = array(
'taxonomy' => 'category',
'orderby' => 'name',
'order' => 'ASC'
);
$cats = get_categories($args);
foreach($cats as $cat) {
?>
<a href="<?php echo get_category_link( $cat->term_id ) ?>/" class="<?php echo $cat->term_id == $category->term_id ? 'active' : null ; ?>">
<?php echo $cat->name; ?>
</a>
<?php
}
?>
content_copyCOPY
Comments