I’m just trying to turn off the wp admin bar on one page, but this function removes it from every page. What am I missing?
<?php
if ( !is_page('image-upload') ):
show_admin_bar(false);
endif;
?>
I’m just trying to turn off the wp admin bar on one page, but this function removes it from every page. What am I missing?
<?php
if ( !is_page('image-upload') ):
show_admin_bar(false);
endif;
?>
You must be logged in to post a comment.
You need to remove the (!) infront of the conditional, you can read about PHP-operators here.
Now you simply say that if not on page “image-upload” remove the admin_bar.. Here is the working code:
Just an example to understand the conditional:
Hide Admin Bar for everyone
This one is reasonably simple, to hide the WordPress Admin Bar for everyone, add the following to your themeâs
functions.php
file, the first bit hides the admin bar, the second bit hides the settings:Hide WordPress Admin Bar for specific requests
This would allow you to hide the WordPress admin bar by going to
example.com/?bar=no
, you can of course change those values.To hide the WP Admin Bar and the Admin Bar preference on his/her profile page for a specific user, add the following to your theme’s
functions.php
file:Or you could do the reverse, and enable the WordPress Admin Bar just for one user, by disabling it for everyone else:
It should be
<?php
if ( is_page('image-upload') ):
show_admin_bar(false);
endif;
?>
remove ‘!’ from !is_page