• Resolved RiccardoCav

    (@riccardocav)


    Hi everyone
    as stated in the title, I want to remove the “Category archive:” text from page titles.

    Here is an example:
    https://riccardocavaliere.com/category/reportage-e-descrizioni/

    on this page I’d like to take away the word “Categoria:” from the title.

    How do I do?
    I created a child theme with its functions.php file.

    Can I use WordPress CSS editor to solve this or do I have to work on a php file?
    Thanks in advance!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hey there RiccardoCav,

    Have to say that you have an original profile image ??

    This should be possible with CSS in case you’re looking to remove the whole page title for category pages. To do that please try adding the following CSS code in the style.css file of your child theme or if your theme doesn’t have custom CSS tab add it in your site using the following plugin:

    https://www.ads-software.com/plugins/simple-custom-css

    .archive.category header.page-header {
        display: none;
    }

    Hope this helps ??

    Cheers,
    Bojan

    Thread Starter RiccardoCav

    (@riccardocav)

    EHi thanks a lot, but this is not exactly what I was looking for:

    I tried the code you suggest and this makes the whole title on the page disappear, which is not what I was looking for.

    I just wanted to make the word “Categoria” (the equivalent of “Category Archive”) disappear, without deleting the page’s title (in this case “Reportage e descrizioni”).

    Any clue?

    Hey RiccardoCav,

    In this case we can’t really do this with CSS as this is part of the same element.

    I’ve decided to check your theme and try doing this with translation files but that didn’t work well, so I guess we can use jQuery to replace text with nothing instead.

    I tested the code on my sandbox site and it worked, please try adding the following to your theme functions.php (ideally you’d want this in your child theme or added as a mu plugin so you don’t lose it once you update the theme):

    add_action('wp_footer','my_category_text_replace');
    function my_category_text_replace(){
    ?>
    <script>
    jQuery(document).ready(function() {
        jQuery(".archive.category h1.page-title").text(function () {
           return jQuery(this).text().replace("Categoria:", "");
        })
    });
    </script>
    <?php
    }

    This should remove that text only from only category archives title.

    Hope this helps and have a great weekend!

    Cheers,
    Bojan

    Thread Starter RiccardoCav

    (@riccardocav)

    Hi,

    thanks a lot! I tried adding this code to my child’s theme functions.php, but it didn’t work…

    Here’s how my functions.php’s code looks now

    <?php
    
    add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' );
    function enqueue_parent_theme_style() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
    }
    
    add_action('wp_footer','my_category_text_replace');
    function my_category_text_replace(){
    ?>
    <script>
    jQuery(document).ready(function() {
        jQuery(".archive.category h1.page-title").text(function () {
           return jQuery(this).text().replace("Categoria:", "");
        })
    });
    </script>
    <?php
    }

    Did I do anything wrong?

    Hey again RiccardoCav,

    I tested the code on my end and everything worked fine, the code looks good.

    Do you maybe have some sort of caching on your site? If yes please try clearing cache to see if this is just a caching issue?

    If no please try placing it in the original theme functions.php to see if that will make a difference.

    Cheers,
    Bojan

    Thread Starter RiccardoCav

    (@riccardocav)

    Hi Bojan,

    actually the weird thing is that your solution seems to work perfectly if I open the site with my mobile phone but if I open it on a computer (I tried from 3 different computers) I still see the word “Categoria” in the heading.

    I wonder what could that be…

    try to use a filter similar to what I describe here https://www.transformationpowertools.com/wordpress/customize-the-category-archive-page-title

    example code for your problem:

    add_filter( 'get_the_archive_title', 'remove_category_word_in_archive_title' );
    
    function remove_category_word_in_archive_title( $title ) {
        if ( is_category() ) $title = str_replace( 'Category:', '', $title );
        return $title;
    }

    you might need to use 'Categoria:' instead of 'Category:'.

    if that does not work, ask in https://www.ads-software.com/support/theme/resonar#postform

    Thread Starter RiccardoCav

    (@riccardocav)

    Thanks a lot Michael.

    Actually Bojan was right: its code is working, probably the website’s appearence didn’t change because there was a cached version, but now finally the word “Categoria:” disappeared.

    I’ll try creating a new category page as soon as I got time to double check and then I’ll change this thread status to “solved” if it works.

    Thanks a lot!

    Thread Starter RiccardoCav

    (@riccardocav)

    Ok, so….
    Bojan, thanks a lot again, your method is definitely working and I’m supergrateful.

    All the best!
    Riccardo.

    Hey again Riccardo,

    Awesome! Glad to hear this was just a caching issue ??

    Have a great day!

    Cheers,
    Bojan

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Remove "Category archive:" on a category page’ is closed to new replies.