For the heading on a category archive use either:
the_archive_title();
Or:
single_term_title();
The first one can be used on the template for any archive, while the second should only be used on category, tag, or taxonomy archive templates.
You shouldn’t need to get anything from any of the individual posts. They may have other categories and the category relevant to the current archive might not be the most relevant.
Related Posts:
- Use category base slug in posts’ permalink
- How to control which category will be picked for the slug of a post?
- How do I get the slug of a custom taxonomy category of a post?
- Mark menu item as current-menu-item for category
- Exclude category from
- Disable sticky option for specific categories
- Redirect to another page using contact form 7? [closed]
- how to hide empty fields of post category description?
- Give posts a particular template based on the assigned category
- How to 301 redirect from url with post id to permalink with post name (slug)?
- Show all posts in category
- Change from all posts to specific categories post on main page?
- How to add category to: ‘wp-admin/post-new.php’?
- Setting Custom Sort Order of Posts within a Category
- Display the latest post from a category in a page
- How to show list of posts by author and category?
- Change the Slug of Post Type post to baseurl/post/%postname%
- Exclude posts that only have the ‘Uncategorized’ category [duplicate]
- Change slug with custom field
- Add default content to post (for specific category)
- Query only Posts from Both of Two Category?
- How do I change the gallery that is inserted in the post?
- Display most recent post in category instead of archive?
- Use template of parent category for single post sub-categories
- Post in Multiple Categories to stay in current category (permalink, next previous post link)
- get_post_type_archive_link(‘post’) returns current category archive
- Get user’s most published categories
- Conditional that checks if a current category has any subcategory with posts
- How to set post expiration date and time and move the page to archive after expiration [closed]
- Exclude posts from featuring
- Articles are text-only in any “Category” instead of HTML
- Random post category URL
- Bulk update post slugs through database
- How To Remove Certain category Posts From the Blog Page
- Add icon/badge next to posttitle of specific category
- Admin Notices don’t display on the admin screen for certain post
- I am unable to publish/update post
- Custom WordPress Theme: Publish Date and Display Date for posts right beside each other
- Get current category id from post page wordpress
- Saving category to a post, before publishing the post
- Assign category to new post via URL
- Stop users posting into category while still seeing contents of the category
- get_the_excerpt() is not working as expected – returns wrong text
- Category Page Template not Showing Posts
- How to Restrict Previous & Next Post Link to Posts of Same Category?
- WordPress custom Query for Posts in Category display posts multiple times
- Categories list into registration form
- How to get subcategories from category slug?
- Disable WordPress Archive Conflict Check
- How to display two random-post sections that are each under their own category
- How to create a sub post?
- WordPress bulk category select when publishing post
- Exclude some categories from listing on the current post
- how can i display my posts alphabetically?
- Change Post Title For Specific Category
- In what context should Categories and Tags be used
- list posts from two categories on a page – plugin not working
- How to create a playlist for audio associated with posts per category
- post type slug vs page slug
- Change default post style to columns
- How to add a post class on every post. (on homepage)
- posts going to 2 pages/categories only show up in 1
- What’s a theme that properly handles previews of different types of posts?
- Display Parent Category of a Post belonging only to Subcategory
- Can I style single post that are in multiple catergories?
- Rewriting blog permalinks
- How to make ajax load posts from the current category?
- created post displaying differently on front end
- Show single post child category from a determined parent
- Get post slug and match with menu item slug to change css
- How can I create a ‘sub-blog’ which has its own sidebar on individual posts?
- I want to add the 10 most recent posts under a parent category on the main menu
- how to filter posts by category without page load (ajax) in wordpress?
- How to increase the number posts that displays by a hierarchical taxonomy? (HTTP ERROR 500)
- How to distinguish pages created by woocommerce?
- Moved a website and excerpts don’t work for old posts
- WordPress the_category(); only works with message-posts not with project posts, how do I specify project categories?
- How to display particular categorie’s post which associated to specific user?
- I want to show recent post according to category of the post in single.php?
- Limit amount of categories displayed in a post
- Word /blog/ in slug post, problems in CPT. Solutions?
- Category and Posts in front page
- Allow registering user to select post category when signing up to blog
- how to print total number of posts filtered by category?
- Integrate video and iframe in a post type gallery
- Displaying a specific sub-category’s posts from wp_query
- Nothing appears using get_the_excerpt() in category.php
- Custom plugin to get related posts by category
- Unable to uncheck a category in a post
- Next/Prev category post in same button
- Show category post with excerpt text
- How to show different categories in different pages?
- How to set a link to custom archieve page
- Older entries link within a category page
- how to style an individual page in a category [duplicate]
- each user having category with their name and can add sub categories post in that category
- Can’t assign another category other than Uncategorized int he following front end post submission form?
- exclude certain categories from posts
- Wp_query WooCommerce products
- No matching template found when using single.php