Site logo

Archived topic

dual H1 title in code

8 replies · Started by Jesse on May 10, 2022

Viewing posts 1–9 of 9

Hi Support,
I am using a Category as a page to show my hub posts.
In this Category Page, i will need to remove its own content ( included H1 title and others), i did use css code ".category .page-header {
display: none;
} " to hide the H1 code, and i will use the Block to show the H1 title.
Category H1 is hidden, but it's still showing in code, which i take a screenshot as attached.
How i can disable it?

Regards,
Jesse

Hi there,

if you want to remove the archive titles, then add this PHP Snippet to your site:

add_action( 'after_setup_theme', function() {
    remove_action( 'generate_archive_title', 'generate_archive_title' );
} );

How to add PHP: https://docs.generatepress.com/article/adding-php/

Hi David,
Problemed solved.
Thank you very much.

Regards,
Jesse

Hi David,
I have another question regarding this.
How I can only remove a given category page title, but not others? It's like I'd like to keep the original title for the author archive, and other category pages.

Regards,
Jesse

Hi Jesse,

In that case, you can try something like this instead:

add_action( 'wp', function() {
    if( is_category( 'blue-cheese' ) ) {
        remove_action( 'generate_archive_title', 'generate_archive_title' );
    };
});

Just replace the blue-cheese with the category slug.

Hi Ying,
I did test this code and replaced category slug to mine, but it didn't work.
Is it any error?

Regards,
Jesse

Hi Ying,
It works well now and thank you very much.

Regards,
Jesse

No problem :)

This archived topic is closed to new replies.