It should be noted that both
<?php echo get_the_category_list(); ?>
and
<?php
foreach((get_the_category()) as $category){
echo $category->name."<br>";
echo category_description($category);
}
?>
display ALL categories that are assigned to the current post in the loop.
From your question’s title, I understand that you want to display all available categories that exist in the website, so wp_list_categories()
is more suitable. So using:
<ul>
<?php wp_list_categories(); ?>
</ul>
will return a list of all categories that have been assigned to at least one post. You can see the documentation for the function here.