Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Adding Admin bar only to static pages.


Burt Adsit
Participant

@burtadsit

There is only an option to turn off the adminbar for logged out users. Yes/No for them. Otherwise it’s Yes for everywhere in mu. The adminbar gets generated at every page load in mu. You could disable it completely by default someplace in code and then in the pages that you want it to appear on, enable it before the wp_head() call that your theme makes in header.php

bp registers its need for attention by the calls:

add_action( ‘wp_footer’, ‘bp_core_admin_bar’ );

add_action( ‘wp_head’, ‘bp_core_add_css’ );

You could un-register these calls someplace like functions.php in your theme to turn off the adminbar globally:

remove_action( ‘wp_footer’, ‘bp_core_admin_bar’ );

remove_action( ‘wp_head’, ‘bp_core_add_css’ );

Then in your theme, on the specific pages you want to show the adminbar register the adminbar again before the call to wp_head():

add_action( ‘wp_footer’, ‘bp_core_admin_bar’ );

add_action( ‘wp_head’, ‘bp_core_add_css’ );

In your theme you’ll have to add some logic in header.php to detect what page is being displayed and make the event registration calls.

So, in functions.php un-register the calls and in header.php before wp_head() re-register them. They’ll get turned off again when functions.php loads the next time and the sequence starts again.

Skip to toolbar