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?
- Show posts assigned to multiple categories in current category page
- How to use format post in a pertinent way
- How to allow users to post only in certain category and hide elements from edit page?
- How can i limit the number of posts created per category?
- How to Restrict Previous & Next Post Link to Posts of Same Category?
- Pulling in post category and children within category
- WordPress custom Query for Posts in Category display posts multiple times
- Custom Post Slug same as Parents Category Slug
- Post categories to pages
- How to have posts have a parent in permalink like site.com/blog/postname
- Get user categories with most posts in it
- Unable to restore from backup – how to obtain old blog posts?
- Post page to display specific category
- Get Posts Under Custom Taxonomy
- Get attachments for posts that belongs to a specific category
- Prevent additional top level categories but allow more children
- Need help with category listing!
- Prepending %category% onto default posts fails
- List all categories with featured image from post?
- Automatically add date to the auto generation of post slug
- How to handle broken links created by permalink/slug changes?
- Visting slug for ‘post’ post type shows 404 not archive?
- Categories list into registration form
- Remove Custom Post Type Slug and add Custom Taxonomy to Permalink Structure?
- WP_Query: Mixing category__in and tag__in together
- If in_category not working for multiple single.php pages
- How can I setup a relationship using categories in WordPress?
- how do i add posts-page slug before posts slug in permalinks
- WordPress Multisite – Create Default Post and New Category On New Site Install
- how to show single post in a custom template
- Using ajax on editing a category edit page?
- Related posts by category not working right
- How to list recent posts in a wp nav menu?
- Set Default Category to Username
- Dynamic dependent Dropdown lists for categories, sub-categories and posts
- How can I hide tags on a child-category page, if that tag has not been used?
- date issue with category post retrival
- Listing Specific Categories from Current Post with Depth
- How to make multiple sections in home pulling posts category wise?
- Highlight static blog page link in header
- How to display two blog categories as separate sections on one page?
- How to make the first post in the loop be styled like a “new / featured” post?
- How to Mysql select a list of posts with meta_values AND all relevant categories?
- Display post category in foreach loop
- Single.php – Get Current Parent Category
- How to create a template for Pages?
- How do I stop the loop from repeating in my category template?
- get_the_category listing in hierarchial order
- How do I do a page break?
- Is it possible to add/tick a category to a post when it is created?
- Excluding posts not working
- How to get a post’s content? [closed]
- Hide posts belongs to few categories in homepage
- why does wordpress ignore the post args?
- post category in wp_insert_post
- Limit the number of posts a category can have – newest post goes in, oldest one drops out, possible? plugin?
- Block editors annoying warnings
- How to get subcategories from category slug?
- Remove current category from post but display all others
- Disable WordPress Archive Conflict Check
- How show categories in admin and get that selected to show posts in index
- Showing categories and subcategories with posts
- Change default category when I publish a post
- What does WordPress do if I save a post without content/title? [duplicate]
- store posts_id of category into a varable?
- How to display two random-post sections that are each under their own category
- How can you display all sibling categories to a post?
- How to add a class to edit_post_link?
- Loop doesn’t exclude the specified category in home page
- Display posts of specific category term
- Widget that shows categories with posts numbers
- How to create a sub post?
- Admin – no Featured image choice in create new/page|post
- Is there a way to create a meta box that can be added multiple times to a post dynamically?
- Post Image not displaying in category view
- How do I show posts from another wordpress installation?
- Two Custom Post Types with Identical Articles Competing for the same Slug
- WordPress custom post type with folder structure in slug
- get posts from Custom Post Type & Category
- Category page when using static front page
- Latest posts by category — how to exclude current post?
- How do I include the category next to the title of a post?
- Relative number of post in category
- How to create a “latest news” page showing a list of posts from blog category
- WordPress bulk category select when publishing post
- Exclude some categories from listing on the current post
- How to show a custom taxonomy in the theme?
- How to import nested categories from XML file?