So I’m using WordPress in a ‘themeless’ manner, i.e. not using a “blog” template. My site files are in the root directory (not in the theme folder), and WordPressis installed in its own /wordpress/
directory. The only thing my theme exists for is customization of the back-end, including re-branding and custom post types. (I’m basically avoiding plug-ins and widgets and doing a bespoke implementation of WordPress)
With this set-up, is there a way I can get the admin bar to display when my clients view the front-end pages like it normally does?
NOTE: I’ve tried adding wp_head()
and wp_footer()
to no avail. I think this might have something to do with my custom file structure.
Maybe you have to remove some things from the footer-file (e.g. Powered By WordPress). With
var_dump( $wp_actions );
you can see which actions was executed (a list of action hooks). And withvar_dump( $wp_filter['wp_footer'] );
you can see which actions are registred for the specific hook (herewp_footer
).If WordPress is being loaded from an external PHP file by including
wp-blog-header.php
and theWP_USE_THEMES
constant is set tofalse
, thetemplate_redirect
hook will not be fired. This is important becausetemplate_redirect
is how the Toolbar is initialized on the front end. Taking a look atdefault-filters.php
we can see where the Toolbar is initialized:A function can be added via plugin or theme to trigger the initialization of the Toolbar:
Note that
_wp_admin_bar_init()
is considered an internal function for WordPress so use it at your own risk.See also Admin Bar (Toolbar) not showing on custom PHP file that loads WordPress.
More details on loading WP using an external PHP file: What is the correct way to use wordpress functions outside wordpress files?