How to Remove 'Category:' Prefix from Archive Titles in OnePress
Content
Many OnePress theme users want to customize their category and tag page titles by removing the default prefix, such as "Category:" or "Tag:". This is a common request for a cleaner, more professional look. This guide will explain why this happens and provide the most effective solutions.
Why Does the 'Category:' Text Appear?
The prefixes "Category:" and "Tag:" are generated by WordPress core functionality. They are part of the default archive title structure. The OnePress theme, like many others, displays this default title on its archive pages. This is not a bug but the intended behavior of WordPress.
Method 1: Add Custom PHP Code (Recommended)
The most robust and commonly recommended solution is to add a small snippet of code to your site. This code filters the archive title and removes the prefixes.
- Use a Child Theme: It is crucial to make this change in a child theme. This prevents your customization from being overwritten when the OnePress theme is updated. If you haven't set one up, you will need to do so first.
- Edit the functions.php File: In your child theme's directory, open the
functions.phpfile. - Add the Following Code: Paste the code snippet below at the end of the file.
add_filter( 'get_the_archive_title', function ($title) { if ( is_category() ) { $title = single_cat_title( '', false ); } elseif ( is_tag() ) { $title = single_tag_title( '', false ); } return $title; }); - Save the File: After saving, clear your site's cache (if you use a caching plugin) and refresh your category pages. The prefix should now be gone.
This method has been confirmed by multiple users in the community forums as an effective solution.
Method 2: Use Custom CSS (For Hiding Page Header)
If your goal is to remove the entire title header section on category or tag pages, not just the prefix, you can use CSS to hide it. This is a simpler but less granular approach.
- Navigate to Appearance > Customize > Additional CSS in your WordPress dashboard.
- Paste one of the following CSS snippets into the box:
/* Hides the header on ALL category and tag pages */ body.category .page-header, body.tag .page-header { display: none; } /* Hides ONLY the entry title */ .entry-title { display: none; } - Click Publish to save your changes.
Note: This CSS will visually hide the element but it will still be present in the page's HTML code.
Important Considerations
- Child Theme is Essential: Always use a child theme for code modifications like the PHP snippet. Modifying the parent theme's files directly is not recommended and will lead to lost changes after an update.
- WooCommerce vs. Standard Categories: Some solutions may behave differently on standard post category pages versus WooCommerce product category pages. The provided PHP code primarily targets standard WordPress taxonomies.
- Clear Caches: After implementing any of these changes, remember to clear any caching mechanisms you have on your site (server, plugin, or browser cache) to see the results immediately.
By following these methods, you can successfully customize your archive page titles to achieve a cleaner design that better fits your website's branding.
Related Support Threads Support
-
How to hide woocommerce “category:” text in category product pagehttps://wordpress.org/support/topic/how-to-hide-woocommerce-category-text-in-category-product-page/
-
Adding intro text to Woocommerce Shop Pagehttps://wordpress.org/support/topic/adding-intro-text-to-woocommerce-shop-page/
-
Remove Category title and description in woocommerce pagehttps://wordpress.org/support/topic/remove-category-title-and-description-in-woocommerce-page/
-
Remove Categorieshttps://wordpress.org/support/topic/remove-categories-5/
-
Hide “categories :”https://wordpress.org/support/topic/hide-categories-10/
-
How to show breadcrumbs?https://wordpress.org/support/topic/how-to-show-breadcrumbs-3/
-
Category Description/Excerpthttps://wordpress.org/support/topic/category-description-excerpt/
-
How to remove….https://wordpress.org/support/topic/how-to-remove-34/
-
category view not conforming to worpdress settingshttps://wordpress.org/support/topic/category-view-not-conforming-to-worpdress-settings/
-
/#tab-description page product problemhttps://wordpress.org/support/topic/tab-description-page-product-problem-2/
-
Woocommerce issueshttps://wordpress.org/support/topic/woocommerce-issues-11/
-
Remove WooCommerce Headershttps://wordpress.org/support/topic/remove-woocommerce-headers/
-
Woocommerce shortcodehttps://wordpress.org/support/topic/woocommerce-shortcode-5/
-
How to remove the word Category?https://wordpress.org/support/topic/how-to-remove-the-word-category/
-
How to collapse long description on product pagehttps://wordpress.org/support/topic/how-to-collapse-long-description-on-product-page/
-
How to remove the word & move the word of post?https://wordpress.org/support/topic/how-to-remove-the-word-move-the-word-of-post/
-
Changing title of category pageshttps://wordpress.org/support/topic/changing-title-of-category-pages/
-
I can’t modify Woocommerce product image sizehttps://wordpress.org/support/topic/i-cant-modify-woocommerce-product-image-size/
-
Tracing Toolhttps://wordpress.org/support/topic/tracing-tool/
-
Category Page Header Imageshttps://wordpress.org/support/topic/category-page-header-images/
-
Remove taxonomy type from the title of a category pagehttps://wordpress.org/support/topic/remove-taxonomy-type-from-the-title-of-a-category-page/