The function get_the_category()
returns an array of category objects. To get the name of the first category, use this:
$categories = get_the_category();
$cat_name = $categories[0]->cat_name;
For a list of the properties of the category object, see the documentation on get_the_category()
Related Posts:
- Remove “Category Archives: title” at the top of a category page [duplicate]
- Display all posts with same title
- Single_cat_title() print the title before text
- Add title, post content, and category like add_post_meta and update_post_meta
- How to remove “Category : …”
- How to remove category titles?
- Hard coded main navigation
- how to remove the default title of Categories widget
- How to Remove a Title from All Category and Tags Page?
- About title on a page
- Set category page title in custom theme [closed]
- Show different title on category page
- Output Title of Post’s Current Category
- Shop Category Pages missing s
- Include a page’s “category” in its URL
- Category name as page title
- How to auto update post title and slug with category name when post status is updated
- How do you add Author and date Published on Category Pages?
- how to display page title only for child category pages
- Weird html output of single_cat_title – is not inside of the html element?
- How to hide my categories pages’ names, and how as well to reduce the space beween my sidebar’s widgets?
- Could not insert term into the database
- Activate Gutenberg in category-descriptions
- How can I get category ID by category name?
- How would I increase the Author Role to be able to add a new category?
- Randomise results from a category page?
- Adding Custom User Profile data based upon Categories
- Only show category to certain user levels without plugin
- Custom Query to search through categories
- Order posts by category name
- How can I make wp_list_categories output li with category-slug as class, for its children?
- Get sticky post from category?
- Remove word “Category” from WooCommerce product page [closed]
- Output link to category from WP_Query loop of woocommerce products
- Display name of the last child category
- Collapse subcategories in post edit screen
- Categories: A Greenhorn Question on Strategy (Not Code)
- Using a portfolio_category slug in wordpress URL
- How do I specify more than one category?
- How to provide value for ‘selected’ on wp_dropdown_categories() for ‘multiple’ options
- Need Category RSS Feed that shows all posts
- Nav menu category links not showing
- Making a tourism information website [closed]
- Exclude a category from the_category in the single post page
- Post publish directly in all categories except one need pending review
- Display category posts before others category custom query [closed]
- Get Prevous/Next Post Specific Category Without Excludes
- Pagination is not working properly in Product Category/Tag pages
- add_rewrite_endpoint returns 404 on archives
- Multiple category archive page
- List subcategories of active parent category (WooCommerce)
- How to display post type and category links in foreach WordPress code
- Get posts under a category with SQL
- Inside a loop, how to change CSS class based on category name?
- Randomly load categories with latest post
- Is it possible to remove from default category widget?
- How to create a custom meta box field in category? [duplicate]
- How to show 1-5 of X Total Results
- Combine “category search order” with “don’t display child posts”
- SQL query to return categories and category parents
- category__not_in and id values from variable
- WordPress Show Parent Category Description for Sub-categories
- If x comments in a post move post to category y
- Count tags for a specific category
- Adding additional content on post depending on post categories
- Root category template?
- Getting the Most Recent Posts from Multiple Categories
- wp_list_categories not excluing multiple ids
- Add Date & Author Meta to Category Archive Page
- A dropdown with checklist
- Custom meta boxes ID prefix showing on first category but not others
- Exclude category from foreach loop
- How to store category and tags separatly on wordpress?
- Show Secondary Sidebar on Category pages (archive)
- Get categories of queried posts
- Get post content intro text on category.php?
- Conditional category query breaking?
- Different header for each category
- Unable to browser posts in categories
- 3.1 post formats and specific categories/custom taxonomies
- sidebar troubles, taxonomy trouble
- Code for Category, Tags, Archive URLs
- Duplicate new categories across multisite network
- Inline If statement to echo CSS [closed]
- Template category.php with page (no posts)
- How to create Child Category page from scratch at wordpress?
- How to insert category to post via php?
- How to set featured image as background for a specific category?
- Show Subcategory Name Instead of Parent Category
- Limit Category/Tag Dropdown To blog_id in Multisite Install With Global Categories/Tags
- Adding relevant categories to related post
- Code to display category-specific single.php is overriding normal single.php, too
- How can I add a Categories page link to a menu? [closed]
- Media Library filter returns undefined function get_current_screen
- Custom built theme won’t filter categories
- Way to show content of a post, but if exceeds character limit revert to excerpt?
- get IDs from links categories
- get posts from 2 categories. (2 posts)
- Display all subcategories for a product category in woocommerce
- Why does my WordPress index has a category?