[Resolved] dual H1 title in code

Home Forums Support [Resolved] dual H1 title in code

Home Forums Support dual H1 title in code

  • This topic has 8 replies, 3 voices, and was last updated 3 months ago by Ying.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #2215764
    Jesse

    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

    #2215916
    David
    Staff
    Customer Support

    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/

    #2216616
    Jesse

    Hi David,
    Problemed solved.
    Thank you very much.

    Regards,
    Jesse

    #2216654
    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

    #2216741
    Ying
    Staff
    Customer Support

    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.

    #2217039
    Jesse

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

    Regards,
    Jesse

    #2217050
    Ying
    Staff
    Customer Support
    #2217079
    Jesse

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

    Regards,
    Jesse

    #2217796
    Ying
    Staff
    Customer Support

    No problem 🙂

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