Support » Theme: Twenty Twenty-One » How to remove “Category” word from title in twentytwentyone

  • Hello,
    I want to remove word “Category: ” from the category title on category pages.

    I’ve added following function in my functions.php in my child theme but this code doesn’t have any effect. What am I doing wrong or how to fix it with function if possible?

    <?php
        add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles', 11 );
    
        function my_theme_enqueue_styles() {
            wp_enqueue_style( 'child-style', get_stylesheet_uri() );
        }
    
        function amelia_remove_category_title( $title ) {
            if ( is_category() ) {
                $title = single_cat_title( '', false );
            }
            return $title;
        }
        add_filter( 'remove_the_archive_title', 'amelia_remove_category_title' );
    • This topic was modified 1 month, 1 week ago by Psychic Amelia.
    • This topic was modified 1 month, 1 week ago by James Huff. Reason: redundant link removed

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator James Huff

    (@macmanx)

    Volunteer Moderator

    It looks like you were able to take care of it. 🙂

    For anyone finding this thread, there’s instructions here on how to do it 🙂

    Oliver

    Thread Starter Psychic Amelia

    (@psychicamelia)

    Hello James, I manage to do it by creating template file and not with the filter. I wanted to know why the above filter doesn’t work. To Oliver, I’ve seen that thread before, the CSS route is not the best way. I just wanted to know if something is wrong with the filter method I’ve written above?

    Hi Amelia,

    Your filter doesn’t work because remove_the_archive_title isn’t a valid filter hook as far as I’m aware.

    Oliver

    Thread Starter Psychic Amelia

    (@psychicamelia)

    Thanks Oli, yes that makes sense. It was solution mentioned on some other website which I copied.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.