FrenchyNYC
FrenchyNYC

Reputation: 337

How to remove adminbar in Wordpress on certain pages

I try to remove the toolbar/adminbar on my main page when users are logged in but it doesn't work properly. Actually it doesn't work.

I found this code :

add_action( 'after_setup_theme', 'my_website_remove_admin_bar' );
function my_website_remove_admin_bar() {

   // hide the admin bar on your main page
   if ( is_home() )
      show_admin_bar( false );


}

I try to have it out of my homepage...

Upvotes: 0

Views: 219

Answers (1)

rnevius
rnevius

Reputation: 27092

The show_admin_bar filter would be much more appropriate in this case:

function conditional_hide_admin_bar() {
    return is_front_page() ? false : true;
}
add_filter( 'show_admin_bar', 'conditional_hide_admin_bar' );

Upvotes: 2

Related Questions