Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress From Bootstrap to WordPress Setup a Bootstrap Theme Creating Bootstrap Navigation in WordPress

cannot remove admin bar with filter, and body css in style.css not adding margin

when I add the filter add_filter('show_admin_bar ', ' __return_false'); the admin bar does not disappear.

also, when I add the body rule .admin-bar .navbar-fixed-top {margin-top: 30px} the margin is not added to the top of the page.

Is anyone else experiencing this? Does it have anything to do with the update a few days ago?

4 Answers

what version of wordpress do you have? are you putting that filter in the functions.php?

have you inspect the element body using your browser developer tools to see if the body has the class admin-bar and navbar-fixed-top?

I am putting the filter in functions.php. Turned out to be a spacing issue between the single quotes and the parenthasees.

I still cannot get the margin issue fixed though. I inspected the admin bar and found the class to be wpadminbar , so it was slightly different than in the video, but Zac does instruct us to inspect it ourselves, so my bad. The navbar-fixed-top class is active, so I'm at a loss. Probably a slight syntax issue like the one above.

Sarah Jee Watson
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Sarah Jee Watson
UX Design Techdegree Graduate 28,197 Points

wpadminbar is for the actual admin bar, the section that we're applying the margin to is behind/below that? I'm having the same issue, cannot add the margin to put content below the admin bar.

Yes the body has the class admin-bar. Yes the nav is still navbar-fixed-top.

If I change

 .navbar-fixed-top {
top: 0;
}

to top: 30px in the inspector it works, but this code doesn't work when I add it to my actual css?

Anyone else having same issue? WP 4.3.1

in functions.php, check the directory of your style.css, the line of code that enqueues should be: wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css');

make sure you added the forward slash preceding style.css

in functions.php, check the directory of your style.css, the line of code that enqueues should be: wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css');

make sure you added the forward slash preceding style.css

At first my margin did not show up. For me it turned out I had a typo I typed a / instead of a ? for the opening php tag in the style.css page. I had <body </php body_class(); ?>> Once I fixed this it worked for me.

in functions.php, check the directory of your style.css, the line of code that enqueues should be: wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css');

make sure you added the forward slash preceding style.css