How to get categories in wordpress custom theme

When a viewer clicks on a link to one of the Categories on your site, he or she is taken to a page listing the Posts in that particular Category in chronological order, from newest Posts at the top to oldest at the bottom. There are many display choices, including whether to display the complete post or post excerpts, and what additional information to display (title, author, publish date, last modified time, etc.). Each theme makes different choices, and you might want to change them.

index.php / page.php

<?php 

$cat = get_categories([
    'taxonomy' => 'category'
]);

foreach ($cat as $key => $category) {
   echo '<a href="'.get_category_link($category->term_id).'">'.$category->name.'</a><br/>';
}

?>

Leave a Reply