Today I wanted to display a category title outside of The Loop using the category’s id in WordPress. Many thanks to Eric Johnson for providing the solution:
<?php $categoryTitle = get_the_category_by_id(105); ?> <?php echo $categoryTitle; ?> |
Note: “105” is the id of the category.