Site logo

Archived topic

Disable Element Does Not Work on CPT header.

3 replies · Started by John on August 1, 2022

Viewing posts 1–4 of 4

I have this page which displays the archive for a custom post type of tips. Thanks to David's help I used a block layout element to change the content—brilliant!

https://www.morganscloud.com/jhhtips/

But I would also like to change the default content header which comes from the register CPT code. I thought I could do that with a layout element to turn off the content header area but it does not work. I verified I was targeted right by turning the footer off and that worked fine.

I'm guessing there is some good reason why an element won't turn off the content header on an archive, and if that's the case I'm thinking I will just hide the header with CSS and then build my own content header in the already created block layout element.

But before I do that I just wanted to check in and see if, once again, I'm making this harder than it needs to be?

Thanks

Hi there,

the post type archive headers have their own special place that are not currently covered in the Disable Elements.
But you can use this PHP Snippet to unhook the title. Just change the my_custom_post_type slug to your CPTs:

add_action('wp', function(){
    if ( is_post_type_archive( 'my_custom_post_type' ) ) {
        remove_action( 'generate_archive_title', 'generate_archive_title' );
    }
});

Thanks David,

Way better than my proposed CSS kluge.

Glad to be of help!

This archived topic is closed to new replies.