WordPress get_bloginfo()

WordPress’ bloginfo() is use to display information about your site such a the name or the or the template directory.

You can use it like this:

<?php bloginfo(‘template_directory) ?>

What you can’t do is to assign it to a variable. Why? because bloginfo() prints its output to the browser and create an error. If you want to use is at a variable or evaluate it then simply use the “get_” prefix like this:

<?php $template = get_bloginfo(‘template_directory) ?>

The difference is get_bloginfo() will return a value instead of echoing it.

WordPress Codex

The WordPress codex is an amazing resource for WordPress developers for more information about bloginfo() and get_bloginfo() check it out.

Sass WordPress image alignment

When you are writing a wordpress theme from scratch you are probably going to need to write some css to get the image alignment classes in the WordPress editor to do something meaningful. If you are using sass to preprocess your css here a simple sass placeholder class that you could use in your in your theme and everytime you start a new one. I have created a gist on github that is really basic alignment stuff that you will probably always need. You can use it in your theme’s sass files simply by including it and then extending your post or page classes.

.post{ 
  @extend  %post__img;
}

 

Plugins in WordPress can’t be deleted or installed?

If you can’t add or delete plugins in WordPress then you have probably messed up the user capabilities for your administrator roles. I did this when I moved a WordPress multi-user account to a standalone WordPress install. To fix this you are going to have to edit your WordPress database. User capabilities are stored in the database in the wp_options table as a serialized array. Understanding how the array is serialized is the key to fixing this issue. Here is how to go about it.

Editing Serialized Data

If you are going to do this then you need to backup your database. Editing as serialized array is not for the faint-hearted. Remember if you are adding or removing keys you need to update the length of the array otherwise it will break so use this information with caution.