I’m trying to make the category the title of the page. for example if a user clicks on a category and goes here:
My page will show everything in that category with the title of “Camping”
However, my problem is that a lot of posts have multiple categories and my current code is getting the “first” category present, and not the main category that all the posts have in common
<h1 class="page_title"> <?php $category = get_the_category(); echo $category->cat_name; ?> </h1>
- The topic ‘Get Category of Page that item is on.’ is closed to new replies.