Remove "Category:" in title of Archives page?

Hello,

Is there a way to remove the word “Category:” in the title of Archives page? For instance, I have an archives page for Recipes and the title of the page is “Category: Recipes”. I would just like it to say “Recipes.” THat is the same for any archives page, such as “Category: Nut-free,” I would prefer it to just say “Nut-free.”

Thanks for your help!

Heather

Hello Heather,

It can be done by adding the following function into your child theme’s functions.php file or you can use the My Custom Functions plugin without a child theme.


add_filter('get_the_archive_title', 'greatmad_child_archive_title');
function greatmad_child_archive_title(){

	if( is_category() ) {
	   $title = single_cat_title( '', false );
	}

	return $title;

}

Regards,
Kharis

1 Like

I’m sorry. That didn’t work. This is what I have now in the functions.php folder. Am I missing a bracket or something? THanks.

<?php
function my_theme_enqueue_styles() {

$parent_style = 'greatmag-style'; // This is 'greatmag-style' for the GreatMag theme.

wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
    get_stylesheet_directory_uri() . '/style.css',
    array( $parent_style ),
    wp_get_theme()-&gt;get('Version')
);

}
add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ );
?>

add_filter(‘get_the_archive_title’, ‘greatmag_child_archive_title’);
function greatmag_child_archive_title(){

if( is_category() ) {
   $title = single_cat_title( '', false );
}

return $title;

}

Hello there,

I found bug in your code. You shouldn’t have put new PHP code addition after PHP closing tag (?>). Remove the ?> in these lines:


add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>

You don’t need to put ?> at the bottom line as WordPress does it automatically.

Regards,
Kharis

Ok thanks for that. It was also breaking my feed page, so we fixed that. But I still see the “category” in front of recipes. :-/

this is what I have now:

<?php
function my_theme_enqueue_styles() {

$parent_style = 'greatmag-style'; // This is 'greatmag-style' for the GreatMag theme.

wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
    get_stylesheet_directory_uri() . '/style.css',
    array( $parent_style ),
    wp_get_theme()-&gt;get('Version')
);

}
add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ );

add_filter(‘get_the_archive_title’, ‘greatmag_child_archive_title’);
function greatmag_child_archive_title(){

if( is_category() ) {
$title = single_cat_title( ”, false );
}

return $title;

}

I’m having the same problem with GreatMag Pro. I am using the plugin and it has not updated the change. Is there something I am missing?

Hello there,

Try to use the Code Snippets plugin please. Applying a new PHP code as I wrote initially above successfully removes the “Category:” label on category archive page.

Regards,
Kharis

1 Like