:::: MENU ::::
Monthly Archives: June 2012

WordPress 3.3+ Toolbar Removal

I am currently in the middle of a project creating a user database in WordPress and I needed to remove the toolbar on the front end of the website so that users didn’t have access to it. This process is very simple to do.

The basic function that accomplishes this is:

[cc lang=”php”][/cc]

You can add this to your functions.php file, or anywhere in your theme above the wp_footer() function.

If you want to use this only for specific roles, try the following example:

[cc lang=”php”][/cc]

Alternatively, you can create a function to do this if you are developing a plugin, etc.

[cc lang=”php”][/cc]

The only remaining issue with this fix is that there is still a 28px margin at the top of the page that WordPress adds to make space for the admin bar. The best way to remove this is to add a callback to the admin-bar function to remove this space. You should add this into your themes function.php file directly:

[cc lang=”php”] ‘__return_false’));
?>[/cc]

As a closing note, these methods only work on the toolbar on front end of your site, not on the backend.


Displaying WordPress Shortcodes Without Executing Them

While developing for WordPress, there is always a need to write up tutorials that explain how features work. One feature that is especially hard to document, is shortcodes. Why? because when you try to display the shortcode on your post or page, it tries to execute it.

The solution that WordPress offers, which is by far the simplest is to add an extra set of brackets around the shortcode.

[cc][[shortcode_example]][/cc]

Unfortunately, this has been known to not work when multiple examples are used in a single post or when using opening and closing shortcodes.

A workaround can be found using the <code> tag.

[cc][shortcode_example][/cc]

By separating out the first bracket, WordPress is unable to execute the shortcode inside and instead displays it for all to see.


Development Blog

Hello everyone,

Thanks for stopping by.  This blog has been a long time in coming.  My intentions are to use this as a development blog to post snippets of things I learn as I continue to work in web design.  Primarily, I will be posting about PHP, MySQL, Javascript, jQuery, AJAX, CSS and HTML.  You may find a few other things here as I find something interesting that ties into one of the former categories, but I may also decide to just post something random.  Who knows.  I guess you will just have to wait and see, right?

Well, that’s all for now.

-Benjamin

[cc lang=”php”]
[/cc]