WordPress List the Categories in Loop

Are you looking to list the Categories in loop on your WordPress website? Then here you have a solution to list the number of categories which you created. You can use the categories name on your post page or anywhere which would you like by using the get_categories() function.
By using the below code you can display the Category Names which you created in your Post Category.
1 2 3 4 5 6 7 8 9 10 11 |
<?php foreach (get_categories() as $category): ?> <ul> <li> <?php echo $category->name; ?> </li> </ul> <?php endforeach; ?> |
In the above code, you can see by using get_categories() function here we looping the category name. As same like this, you can get the Category Description by using the below code.
1 |
<?php echo $category->description; ?> |
Conclusion:
I hope this code will help you to loop the category names on your website. If you have any doubts about this topic let me know in the comment box. If you really loved this article share it with your friends.
Mraj
Creative Designer & Developer specialist by the spirit and a loving blogger by thoughts. If you have any questions let me drop an email with the article name to the following email id: [email protected]