How to Completely Remove Archive Title a.k.a the_archive_title?

admin2025-06-06  7

I want to remove it COMPLETELY. Not only the label "Archive: " but EVERYTHING. It should not appear. I've been looking for the solution for hours to no avail.

Please help. Thank you!

I want to remove it COMPLETELY. Not only the label "Archive: " but EVERYTHING. It should not appear. I've been looking for the solution for hours to no avail.

Please help. Thank you!

Share Improve this question asked Nov 12, 2018 at 11:29 Syamsul AlamSyamsul Alam 11 silver badge6 bronze badges 4
  • So the page should render as <title></title>? – kero Commented Nov 12, 2018 at 11:32
  • You need to remove it from the template, that's it. – Jacob Peattie Commented Nov 12, 2018 at 11:40
  • @kero if i remove it, are my title tag gonna be empty? I just want to remove the <h1>Archive: Bla3</h1> not removing the title tag, is it possible? – Syamsul Alam Commented Nov 13, 2018 at 3:17
  • @JacobPeattie can you please elaborate in answer, i'm not familiar with removing it from template.. thank you mate. :D – Syamsul Alam Commented Nov 13, 2018 at 3:30
Add a comment  | 

2 Answers 2

Reset to default 0

You can add the following function in the functions.php of your child theme.

add_filter('get_the_archive_title', 'my_get_the_archive_title' );
function my_get_the_archive_title( $title ) {
    if ( is_category() ) {
        $title = single_cat_title( '', false );
    } elseif ( is_tag() ) {
        $title = single_tag_title( '', false );
    } elseif ( is_author() ) {
        $title = '<span class="vcard">' . get_the_author() . '</span>' ;
    }

    return $title;
}

Basically I'm adding this code in my theme's / child theme's function.php

add_filter('get_the_archive_title', 'my_get_the_archive_title' );
function my_get_the_archive_title( $title ) {
    return '';
};

And voilà it's gone, completely, forever!! Just the way I want it!

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749182570a317051.html

最新回复(0)