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?
- Category and tags are not working properly
- How to remove “Category:” title prefix in Twenty Sixteen theme?
- How to create an automatic MultiColoumn MegaMenu with Categories WordPress
- Is There a Difference Between Taxonomies and Categories?
- List all subcategories from category
- How To Find Out WordPress Category Table in MYSQL?
- Add custom field to Category
- Get Category ID inside Category template
- Only one category per post
- WordPress Multisite – global categories
- Get the children of the parent category
- Get posts from sites in Multisite?
- WP REST API: filter by category 1 AND category 2
- How To Get Parent Category Slug of Current Post
- Display All Products by Category with WooCommerce
- What is the difference between a “tag” and a “category”?
- Is there an easy way to make a meta box have the tabs like the Categories meta box has?
- How to check if I’m on the last page of posts?
- Display posts from the same category using next/previous post link
- How would I get a taxonomy/category list inside a Gutenberg block?
- Can I set a default featured image for a category?
- Check if a post is in any child category of a parent category
- How to export and import taxonomies (category, tag and/or custom taxonomy) and their terms
- Force category choice before creating new post?
- Gutenberg editor add a custom category as wrapper for custom blocks
- WooCommerce: List All Categories
- Get category ID from category slug (not working)
- How do I remove “Uncategorized” from posts with more than 1 category?
- Get rid of WordPress category, tag and author archives?
- Individual rss feed entry length for categories?
- How can I create a category landing page followed by pages of posts?
- Remove parent category from permalink? Basically only have the child category?
- Custom permalink structure leads to be 404 on pagination
- Retrieve Product category ‘NAME’ by product category ID – WooCommerce?
- Display random categories on the front page (Finding and Editing Theme Functions)
- Posts URL structure like site.com/category/the-post-title
- Can’t custom taxonomies have same terms (slugs) as categories?
- How to get permalinks with category base working with sub-categories
- How to remove the term “category” from category pagination?
- Using wp_category_checklist in a widget
- WP 3.9 TinyMCE no longer loads on category description editor
- On the category page, get the category object
- Get only the top level categories using get_categories() without foreach loop
- Get all categories and posts in those categories
- How to add featured image for category (without a plugin)?
- How to create a custom sort for WordPress categories
- How to display non-hierarchical taxonomy as terms with checkboxes?
- Category archive by year with permalink support /category/YYYY
- Best Way to Redirect Category to Page and Hide Category