Remove header from CPT


Trying to remove the header from a custom post type. I can remove branding, menu, etc. using beans_remove_action(), but for some reason it doesn't work with beans_header:

function landing_remove_header() {

    beans_remove_action( 'beans_header' );

}

add_action( 'beans_header_before_markup', 'landing_remove_header' );

Am I doing something incorrectly?


Hi Kevin,

If you want to remove the entire header, you can simply add the following:

beans_remove_action( 'beans_header_partial_template' );

Have fun,


That did it! I didn't think to look in the "Render" category in the documentation... Many thanks.


The lib/render/template-parts.php is where the document starts rendering. In other words, all the big blocks on the page.

See it as a loading cascade, first beans_load_document() is called, all the big blocks are attached to beans_load_document action which renders all the lib/templates/structure files (HTML markup) and then all the lib/templates/fragments are called which attached the content to the structural markup. This is how we have so much flexibility from changing big blocks down to changing a single markup attribute πŸ™‚

A fun example

To illustrate the flexibility, you could for example move the header just before the footer with one like of code:

beans_modify_action_hook( 'beans_header_partial_template', 'beans_footer_before_markup' );

Above, we said replace the hook to which the header is attached (beans_site_prepend_markup by default) and instead attach it to beans_footer_before_markup πŸ™‚

We have control over the entire page

Just to show that we have full control and illustrate the cascade, you could litteraly remove the entire page content by removing all actions attached to the root action.

remove_all_actions( 'beans_load_document' );

These two examples above are just to demonstrate and hopefully help to understand the Beans loading cascade πŸ™‚

Have fun,

Write a reply

Login or register to write a reply, it's free!