Skip to:
Content
Pages
Categories
Search
Top
Bottom

Adding Admin bar only to static pages.

  • Hey, I was just wondering if there is an easy way to add the Admin Bar only to the tops of a couple of static pages that I was working on.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Avatar of Burt Adsit
    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.

    Thanks, I’ve got what I need now.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Adding Admin bar only to static pages.’ is closed to new replies.