Set the display
argument of the function to false
.
<h2>
<?php
if (is_category()){
echo 'Category: ' . single_cat_title( '', false);
}
?>
</h2>
Or, to use the function in its more “helpful” form you could do:
single_cat_title('Category: ');
If the display argument is true, WordPress automatically echoes the content on to the page usually within a wrapper html element and this messes with your echo
.
Related Posts:
- How to hide my categories pages’ names, and how as well to reduce the space beween my sidebar’s widgets?
- How to get category and archive title?
- Multiple level category drop-down
- How to create a widgetized sidebar for every category dynamically?
- List Categories of the Parent Category of the Current Category
- Remove “Category Archives: title” at the top of a category page [duplicate]
- Display all posts with same title
- How to get post category title within the loop?
- Edit the markup of categories list
- Add title, post content, and category like add_post_meta and update_post_meta
- How to remove “Category : …”
- How to get data about category in category.php
- editing fonts of category links from the_category() funtion
- How to check category of of custom post type or not
- Set a them for all subset of category
- How to remove category titles?
- Hard coded main navigation
- WP didn’t redirect to canonical category URL
- Custom Walker for wp_list_categories
- How to do some action weekly?
- 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]
- So my theme doesn’t have a category.php file
- Show different title on category page
- Theme for subcategories
- Theme modification for custom category menus
- Output Title of Post’s Current Category
- How to list posts from a sub-category that is listed in a parent category (more details below)?
- How can i add service category here? [duplicate]
- How do I remove “Uncategorized” from my theme on my posts page?
- Shop Category Pages missing s
- Category page 404s on mobile but not desktop?
- Regarding Tags And Categories
- Include a page’s “category” in its URL
- Category name as page title
- Style a category page the same way as the homepage?
- How to auto update post title and slug with category name when post status is updated
- Jetpack Mobile Theme: when on smartphone on categories the theme suddenly changes to jetpack mobile theme even though it’s deactivated
- Choosing different templates for categories
- Show posts from all categories
- How do you add Author and date Published on Category Pages?
- Removing categories, Comments etc from posts?
- Include category name in page template
- altering theme – content generated by PAGES not PORTFOLIO
- Category page with gallery for each post
- Custom built theme won’t filter categories
- how to display page title only for child category pages
- Duplicate homepage to show posts from 1 category
- Weird html output of single_cat_title – is not inside of the html element?
- How to check if I’m on the last page of posts?
- Get top parent category
- wp_update_nav_menu_item() to insert categories
- Redirecting specific category posts to subdomain
- Block multiple categories from Blog
- Best and Cleanest way to remove /category/ from category permalinks? [duplicate]
- Categories list loop – add separator every year
- What type of page should i use? static page or category page? and what’s the difference? [closed]
- Add Category name to Post Title (h1)
- wp_nav_menu not highlighting the current category when viewing a single post
- how to show the post category name
- Find out which user created a category or tag?
- Mod_Rewrite to show only last subcategory in URL
- menu using category and tags
- Have parent category contain only one post?
- wp e-commerce group product by category [closed]
- Limit get_categories to show each category once
- get parent category only
- “Item not updated” when try to change category properties
- How can I tell what category I’m in– in the header?
- new WP_Query all post in a category inside the loop
- How to display sticky or latest published post on the current category page it belongs to?
- Category tags with comma’s
- Filter posts by categories ajax is showing nothing
- How to display child categories of all parent category within a singe loop?
- How can I add a class to displays a category?
- WP_Query – using category__and when one of the categories is 0
- Multiple categories for one menu item?
- Hide categories from frontend, but not admin / post editor
- Exclude categories from homepage not longer working
- Post to inherit custom category background image from parent
- Related posts widget – category
- Editing Loop So It Targets Specific Tags?
- Header Link function not working. Problem with bloginfo()
- WordPress category filters as subcategories
- Sort posts alphabetically by category/custom taxonomy, insert divider between different types
- Modifying category order
- Please tell how to stop the category from showing up on posts
- Remove “category” from permalink with add_rewrite_rule
- Next and previous links category infinite loop
- show only terms from parent category
- Accessible Subcategory URL’s pages without using .php hack
- How to display total views of all posts of one category?
- How to show “category” name?
- filter single_cat_title avoiding the breadcrumbs
- htaccess redirect for all categories converted to tags now showing 404
- Latest Posts not in the right order
- Search functionality with multiple categories
- How to define category ID in an array?