Admin bar appears empty in WordPress - wordpress

Admin bar appears after adding code to the functions.php
add_filter( 'show_admin_bar', '__return_true' );
but empty except for the WP logo and the search on the right.
I installed latest version of twentyTwelve, it didn't appear,after adding the same code to the theme's functions.php it appears with the same problem.
So I don't think it has to do with the theme.. So I deactivated all plugins, And I still have the same problem.
Note: There is no problem with the admin bar in the Dashboard. Also I checked the HTML structure, it's not hidden by CSS.
<?php wp_footer(); ?> + <?php wp_header(); ?> are defined in the themes header and footer.

If the toolbar is forced to load (via show_admin_bar) but a user is not logged in it has nothing to show the user. When this happens it looks exactly like your screen shot with just the WP and search icons present. The toolbar will load anytime a user is logged in though so there is no reason to force it to load unless you intend to modify its behavior to include actions for anonymous users.
I was able to recreate this easily in a clean install but only if there was no user logged in. If this is happening to you when a user is logged in then I suggest a fresh install of WP in a subdirectory, or locally, then enabling your theme and plugins one by one until it breaks so you know which component is causing the problem.

Related

Dashicons in wordpress (frontend) won't display

I'm creating a website in WordPress. I'm using dashicons for rating (manually) holidays.
It used to work, but after update the dashicons won't be visible for non-logged in users. Only, if you login, you can see the star ratings.
The star rating should be visible on the left top of each holiday deal.
Who knows a solution?
Website url is www.ikwilopvakantie.nl
Dashicons is the official icon font of the WordPress admin as of 3.8..
To load Dashicons for non logged in users:
Open directory {your-website-folder/wp-content/themes/}
Go into the folder of your active child theme ( if you don't have active child theme, open the folder of your active parent theme )
Find there functions.php file and add the provided code at the end of it (
make sure, there isn't ?> php closing tag at the end of file. if so, just remove it ):
function ww_load_dashicons(){
wp_enqueue_style('dashicons');
}
add_action('wp_enqueue_scripts', 'ww_load_dashicons');
Save changes. Dashicons will loads on your website for all users.
EDIT: there may be some plugin/code, which removed Dashicons from pages. Try to change your code with this one:
function ww_load_dashicons(){
wp_enqueue_style('dashicons');
}
add_action('wp_enqueue_scripts', 'ww_load_dashicons', 999);
Try this:
<span class="bx-next dashicons dashicons-arrow-right-alt2"></span>
'dashicons-arrow-right-alt2' is the class of the icon.
You can find them here: https://developer.wordpress.org/resource/dashicons/#arrow-up-alt
This has to go to your functions.php file:
function load_dashicons(){
wp_enqueue_style('dashicons');
}
add_action('wp_enqueue_scripts', 'load_dashicons');
For me the problem was simply that my browser blocker addons weren't allowing the source of dashicons.css
If you're using the plug-in "Asset CleanUp", you can navigate to "BULK CHANGES" and easily use "Remove site-wide rule" at the line, where the url for "dashicon" is listed.
Many of the icons on the official list were appearing blank for me when defined as a value of the menu-item property in the register_post_type function.
If you open wp-includes/css/dashicons.css you will see a complete list of icons available, many of which have different names, for example dashicons-quote is actually dashicons-editor-quote.
Using these values solved the problem for me. I also found this cheat sheet to be helpful if you don't want to go digging through your source files.
Solved for me— For some reason, dashicons was only not rendering when I wasn't accessing the https:// version of the site.

WP admin bar not working in front end

My admin bar is not showing on the frontend of my site.
It is set to display on the profile
Tried deactivating and activating all plugins
footer.php is fine
logged off and cleared the cache
Still no progress, can someone pls help.. I'm very new to blogging and have very little knowledge of programming. Thanks.
1) check your function.php if this line is present
show_admin_bar( false );
2) if this is not present then try to add this in your function.php
show_admin_bar( true);

Hide Wordpress dashboard?

I'm new to wordpress and a bit confused with something. I'm trying to build a classified marketplace type of website for myself. I am NOT building this for a "client". I will probably be using a hack of several different plugins as my coding skills are not up to par. Eventually I will hopefully have lots of users who will be composed of buyers & sellers.
My question pertains to the WP dashboard. When buyers/sellers sign up for my site, will they be able to see the backend WP dashboard? I would prefer that they NOT be able to access a backend dashboard at all let alone a WP branded one. Is this possible? If so any clue as to how this might be accomplished?
thank you Brian
Normal users do not actually see the 'backend' WP dashboard. What they are seeing is a 'profile' type page meant for the original functionality of wordpres; being a blog.
If you do not want users to go to this page when they log-in, you can use a couple of hooks. Here is some code that redirects to the front page after logging-in and logging-out. This goes in your functions.php file.
add_action('login_form', 'ang_redirect_to_front_page');
add_action('wp_logout', 'go_home');
function ang_redirect_to_front_page() {
global $redirect_to;
if (!isset($_GET['redirect_to'])) {
$redirect_to = get_option('siteurl');
}
}
function go_home(){
wp_redirect( home_url() );
exit();
}
And, if your theme is still displaying the menu at the top of the screen that allows the users to go to this 'profile' area, you can go into your footer.php file and remove this:
<?php wp_footer();?>
However, if you do this, then you will not see it as the admin either.
WordPress is might not be the thing to use for that kind of website, even with a bunch of plugins. Read up on other content management systems just incase.
This link might answer your question:
http://buddypress.org/support/topic/how-to-prevent-non-admins-from-accessing-wp-admin-dashboard/
You can also add this to your theme's function.php file:
// DISABLE ADMIN BAR FOR ALL USERS
show_admin_bar( false );
If you are not too used to wordpress, use WOOCOMMERCE plugin. Its completely free and well documented

Wordpress Admin Bar Not Showing on frontend of site

Please could anyone help me with this problem? The wordpress admin bar is not displaying on the front-end (public visible pages) of my website. It shows when I'm logged in at the backend i.e Dashboard though. User settings are ok (set to show admin bar when viewing the site). I have tried deactivating (then, re-activating ) installed plugins, still no show.
Just a background note:
I recently transferred the site to my webhost (I was developing locally and everything worked and is still working). And I have a custom folder for wordpress. I was wondering if the problem has to do with this.
Please help I have searched everywhere but seems everyone is looking to hide the admin panel instead.
Thanks in advance
Check that your theme includes a call to the function wp_footer() at some point, usually at the very bottom of footer.php. That generates the code required for the admin bar to show.
add this to the end of your footer.php in your theme folder:
<?php wp_footer(); ?>
problem solved :-)
Most of the time the wp_footer() call is right where it should be so if you still can't see the admin bar then try the following:
log out of the backend
navigate to the front-end
clear your browser cache
log back in using the absolute url i.e. yourwebsite.co.uk/wp-admin
and then see if it comes up - worked for me.
Also make sure the "Show Toolbar when viewing site" box is checked in your user profile page or whatever you try ain't gonna work my friend!.
I know this is an old question, but another option - If you purchased (use) a pre-made theme make sure that theme does not remove the toolbar in its code.
Does it 'know' that you are logged in ? when in front end ? ie: meta widget shows 'logout' instead of login. if not Did you by any chance play around with the cookie paths?
I got myself confused because I was logged in at backend, but not front end. This was because I'd being playing with the cookie path and forgot to uncomment what I'd done.
First, double checked all of the other items mentioned here (wp_footer(), etc).
Three more things to check:
make sure header.php has <body <?php body_class(); ?>> not just <body>
try disabling plugins one by one if you're still having trouble. (For me, the Simplest Gallery 2.7 with WP 3.7.1 caused a conflict that made the admin bar disappear)
look for function remove_admin_bar() { return false; } in the theme's functions.php - change it to return true.
Just add in your template
<?php wp_footer(); ?> before </body> and <?php wp_head(); ?> before </head>
For me the issue was that I was using http://mydomain.com/wp in the WordPress address but http://www.mydomain.com for the site address. We had added the www to the WordPress address so that GoogleAnalytics would work and that's when the Admin Bar broke.
Adding www to the WordPress address fixed the issue.
To clarify after a lot of searching for a solution, similar to MattKnowles solution but more specific: Make sure that in settings > WordPress Address (URL) and settings > Site address (URL) that if one has www then the other also does and the other way round. Otherwise it seems while you are browsing the site it is a different domain to the admin area and the admin bar does not show.
Make sure site addresses are the same! I had one set at http://www.example.com and the other (WordPress) address set to http://example.com or visa versa.
I had them set this way because I though it was needed for the site to show up when you type the url without the www.
Now that both addresses are the same (with the www) my admin bar works, I stay logged in, I can comment, see preview or draft content, cross-site authenticate and logout, wow!
an entire year of wondering why WP just never worked right across over 30 websites!
Going to change addresses to the same "www" address in the rest of my 30 sites now and enjoy error-free WordPress for the first time ever...it's a great day!
Remember to remove any admin bar code you may have added in your theme's function.php file or in your styles.CSS
Thanks to all who help us here!
wp_footer() ,
add this function to footer.php
My #wpadminbar had a z-index: 99999;
In an act of myopia I made a sticky header that was in conflict with the Admin bar's stickiness. I had a z-index greater than the admin, making it rest behind the visible div.
I made my own sticky less powerful.
Here's a solution that I found.
Need to have <? wp_head()?> and <? wp_footer(); ?>.
More info: http://blog.frontendfactory.com/how-to-add-wordpress-toolbar-to-your-custom-theme/
Still working on this, but there is a conflict with Woocommerce. if deactivated, toolbar is there. Active, no toolbar.
More info here.
I had a sitiation when the admin dashboard was opened in one Chrome tab, but I could not make front-end part opened in the other tab to enter the admin state and show the admin bar.
The front-end always opened as if I had not logged in as an admin in the other tab.
The issue was that I had the site opened in yet another Chrome window (not tab) as not-logged-in visitor.
As soon as I closed all the tabs and all the sessions and reopened the single Chrome window with two tabs (admin / front end) the admin bar appeared in the front end.
Beware of unclosed HTML tags above <?php wp_footer(); ?>. Unclosed tags in the source will have closing tags generated by the browser and can suck in the WordPress admin bar HTML.
...
<div class="hidden-by-css">
<span> You can't see this</span>
<?php wp_footer(); ?>
</body>
</html>
That will cause the HTML generated for the admin bar to get sucked into the .hidden-by-css DIV and your admin bar won't show up.
So make sure you close all your tags. :)
I wanna leave my solution since I tried literally every possible solution on the internet. The website has LiteSpeed and is behind a reverse proxy from Deflect.ca similar to cloudflare, it blocks and caches as well.
The problem is the default cache from Deflect is set on 10 minutes and that caused the problem. Setting it with lower settings and removing all admin caching from LiteCache solved everything.

why is the <?php wp_head ?> tag creating a top margin at the top of my theme header

Hey people, I've been coming here for a while but just decided to join.
I'm new to php and I'm trying to make a website with WordPress as the CMS.
Anyway, I'm basically making my own theme because I don't want my website to look like a blog, and it's going pretty smoothly so far but theres this huge top margin gap in the browser even when I set margins to 0px.
I tried trial and error and found out that it's being caused by: <?php wp_head(); ?>
It's two different things.
1. wp_head() function
wp_head() is a template tag to print whatever plugin / theme specific function used by wordpress action. Read codex for more detail about it.
2. The admin bar
The top margin, is generated by wordpress's admin bar.
To fix this for logged in users you can do a couple of things:
Disable admin bar from the admin:
Go to admin panel
Users >> User Profile
Uncheck 'when viewing
site' on 'Show Admin Bar'
Remove the admin bar from your theme entirely:
Open your functions.php
Add this to it:
function my_function_admin_bar(){ return false; }
add_filter( 'show_admin_bar' , 'my_function_admin_bar');
Remove only the code which creates the css:
Open your functions.php
Add this to it:
function my_filter_head() { remove_action('wp_head', '_admin_bar_bump_cb'); }
add_action('get_header', 'my_filter_head');
Note: Extensive updates are from #hitautodestruct
you neeed to call wp_footer() in your footer
just insert this line <?php wp_footer();?> into your footer.php file
If you have updated your wordpress install to the latest version.. there seems to be some bug with the admin bar...
were it would produce an inline stylesheet appended to the top of your pages.. causing the margin-top:28px
see here
1 recomendation is to put a new function into your functions.php file located in your theme folder.. this will completly remove the bar, so no users of your theme will have any of the same issues!
function my_function_admin_bar(){
return false;
}
add_filter( 'show_admin_bar' , 'my_function_admin_bar');
Not sure if this will help.. but worth a shot.. also turning off the admin bar while viewing the front end of the site under your profile page..

Resources