• I don’t seem to be able to remove the text “Category Archive for” that appears when I include a category in my menu.

    Also, the name of the category is shown between quotation marks, and I don’t want that.

    Any ideas on how to fix that?

    I don’t know how I fixed it in the Spanish version of my site (/es/documentos/), but I still can’t get rid of the quotation marks…

    Thanks!

    • This topic was modified 2 years, 8 months ago by Jan Dembowski.

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

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi,
    You can modify your Archive page title by using this function the_archive_title()

    It seems your theme already modified the Archive-title because the default Archive-title format is :

    Category: {Category Name}

    But on your site, it’s already modified. So now if you want to edit this, you have multiple ways.
    1. You can find your theme code where its already modified and customize it as per your need
    2. You can add your own filter hook on the functions.php file
    3. You can create a child theme and there you can modify your archive.php file.

    Here is the 2nd solution

    function wpfy_edit_archive_title($title,$original_title, $prefix){
    
        // Limit it only for category archive
        if(is_category){
            $title = sprintf(__('Category Archive for %1$s', 'textdomain'), $original_title);
        }
    
        return $title;
    }
    add_filter('get_the_archive_title','wpfy_edit_archive_title',10,3);
    • This reply was modified 2 years, 8 months ago by Akramul Hasan.
    Thread Starter sebastianhduy

    (@sebastianhduy)

    Thanks for all those options.

    I’ve tried the first one (editing my theme’s archive.php).

    However, although I managed to remove the rest of the unwanted text, the category names remain with quotation marks, as you can see here:

    https://aniu.org.uy/en/documents/

    I know nothing about php, but but his is how I modified it in order to remove the unwanted text:

    <?php /* If this is a category archive */ if (is_category()) { ?>
    <h1><?php _e(”) ?> ‘<?php single_cat_title(); ?>’ </h1>

    I tried to remove the quotation marks that remain in the code, and the whole site stops working.

    Any ideas?

    Hello,
    Please remove your code from archive.php, keep it as it was.
    You just put the below code into your functions.php file.

    function wpfy_edit_archive_title($title,$original_title, $prefix){
    
        // Limit it only for category archive
        if(is_category()){
            $title = sprintf(__('%1$s', 'textdomain'), $original_title);
        }
    
        return $title;
    }
    add_filter('get_the_archive_title','wpfy_edit_archive_title',10,3);

    It’s working on my side. If still not working, let me know.

    Regards

    Thread Starter sebastianhduy

    (@sebastianhduy)

    Thanks, but it didn’t work, as you can see here:

    https://aniu.org.uy/en/news/

    It started showing the “Archive for” text.

    Any other idea?

    Hi @sebastianhduy
    That was working for me.
    Did you remove your old code completely?
    Did you put my given code on your active theme functions.php file?

    Most importantly make sure the code is on very bottom of the funcitons.php file.

    Here is another code you can try

    add_filter( 'get_the_archive_title', function ( $title ) {
    
        if( is_category() ) {
    
            $title = single_cat_title( '', false );
    
        }
    
        return $title;
    
    });

    This also worked for me, just tested
    https://prnt.sc/OohGersWX9MD

    If still does not work, please send me your archive.php and category.php file

    Regards

    Thread Starter sebastianhduy

    (@sebastianhduy)

    Hey, @wpfy

    Yes, I did remove my old code as you told me.

    No, I hadn’t included it at the bottom of the functions.php file, but now I did and it’s still the same: nothing changed.

    I tried your new line of code and nothing changes.

    Here are the files you requested:
    https://aniu.org.uy/files.zip

    Note: I guess you meant the functions.php and archive.php. I don’t know where’s the category.php file.

    Thanks.

    Hi @sebastianhduy
    Just do these 2 steps.

    1. Take a backup of your current archive.php file. And put the archive.php file I am just giving you
    https://we.tl/t-nd3VvqIIVP

    2. Put the below code in your functions.php file at very bottom

    add_filter( 'get_the_archive_title', function ( $title ) {
    
        if( is_category() ) {
    
            $title = single_cat_title( '', false );
    
        }
    
        return $title;
    
    });
    Thread Starter sebastianhduy

    (@sebastianhduy)

    Awesome! It worked!

    Thank you so much for your help! ??

    Hi @sebastianhduy
    That’s awesome!
    Thanks

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Remove “Category Archive for” form title’ is closed to new replies.