Conditionally remove header widget from Genesis

Genesis comes with a header widget area built in.

Occasionally you may want to remove this for specific pages.

The following code snippet in functions.php will do the trick

add_action( 'genesis_meta', 'my_remove_hr');
function my_remove_hr() {
if ( is_page( 'privacy-cookies' ) ) {
     unregister_sidebar( 'header-right' );

The if statement will need to be adjusted depending on need,  see to see what conditions could be applied.

If you want to remove the Header Right sidebar on the whole site the code is simpler, just add this to your functions.php

unregister_sidebar( 'header-right' );

You can find other header code snippets here on the Studio Press site




, , ,



Leave a Reply

Your email address will not be published. Required fields are marked *