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.

  @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.

Vagrant WordPress

Vagrants is a portable development environments which can be used as part of your web development workflow.
Varying Vagrant Vagrants or vvv is Vagrant configuration focused on WordPress development.
In this screen-cast I  set up a Vagrant WordPress development environment using Varying Vagrant Vagrants. It was pretty straight forward to do. The only thing I assume is that you have Git set already. The biggest headache I encounter was the fact that Varying Vagrant Vagrants is quite possibly the worst name ever.

Setting up a Vagrant WordPress

Vagrant and Varying Vagrant Vagrants looks promising. I’m not sure if I will drop my xamp work flow straight away but I will certainly be keeping an eye on it.

Vintage textile patterns

Here is a selection of 10 Hi-res images for you to feast upon. 10 lovely vintage textile patterns. Use as a whole or enlarge to expose the detail of the fabric. Click on the link below each preview to download or download all the images in one zip file at the bottom of the post.

WordPress $wpdb basics

Access WordPress Database

Starship $wpdb

Recently I’ve been adapting a plug-in to suit my needs and for the first time, trying to write something that interacts with the wordpress database, step up wpdb class!

The WPDB Class – Make it Global

To use the wpdb class we need to access a global variable $wpdb which is simple enough, but what you’ve got to remember is that it needs to be globalized before you use it in your custom function: -

global $wpdb;

Once that’s in place you are free to use it to perform SQL queries and function on your database.

The first thing I needed to do was to query the “commentmeta” table in the database, and save the results for later use: -

$comment_meta = $wpdb->get_results( "SELECT mydata FROM mytable WHERE mycondition = 'myvalue' ");

The above code uses ‘get_results’ to query the database and loads in to the the variable $comment_meta so it can be used in a ‘foreach’ loop later. Now I wanted to grab the meta_key, meta_value from table ‘commentmeta’ that was named ‘wp_1_commentmeta’. I could have put that value into the query but if I want to use the function on a different site on a wordpress network I’m not going to know the database prefix so I can use $wpdb to replace it: -

$comment_meta = $wpdb->get_results( "SELECT meta_key, meta_value FROM wpdb->commentmeta ");

That way I can use the query in a function on any wordpress blog and it will always knows what table to look at.

It’s an Object by default

One last thing to remember is that the results are an object so you can access the like this: -

foreach ( $comment_meta as $comment_meta_data )
echo $comment_meta_data->meta_key
echo '< br />'
echo $comment_meta_data->meta_value

And that’s what I wanted but if you want something different like an array then you can use OBJECT_K for an associative array of row objects, using first column’s values as keys, ARRAY_A for a numerically indexed array of associative arrays, using column names as keys or ARRAY_N for a numerically indexed array of numerically indexed arrays like this: -

$comment_meta = $wpdb->get_results( "SELECT meta_key, meta_value FROM wpdb->commentmeta", ARRAY_N );

for more information on the wpdb class check out the wordpress codex

DNS wildcards on cpanel for wordpress mu

How to add a wildcard entry so your wordpress mu subdomains resolve correctly

If you want to use sub domains for your wordpress mu blogs you are going to need to add a DNS wild card to get it to work. Thankfully if your host provides cpanle there’s a really easy way to do this. Here’s a screencast showing you how.

[screentoaster stUk9RREZIR11bSF5aXl5YVFZT]

Shopify : The current tag as a title


Using tags in Shopify to create nested navigation is a great  way to help customers find products but once they’ve browsed to the tag page you need to let your customers  know what they’re looking at. A collection has the following property for this : -

{{ product.title }}

That works well for collections but tags are slightly different firstly a tag doesn’t have a title so you can’t have{{ tag.title }}. Tags are attributes of products and collections but if you use {{ collection.tags }} you are going to get a list of all the tags associated with the collection, which is not what we want. The function to use is : -

{{ current_tags }}

And voila this will output the current tag which you can use as a title by wrapping it in some <h2> tags or what ever you want. Nice and simple when you know how.

8 Hi-Res Very Distressed Grunge Textures

Hi-Res Textures for Designers

Hi-Res Textures for Designers

Extreme Underground Grunge Posters

Here are 8 free grunge poster textures. The images were taken on underground tube stations in London . I just loved the ultra distressed look of the many layers of posters and thought they’d make quite useful textures so here they are. You can download the hi res versions in 2 zip files at the bottom of the previews. Enjoy.

  • blank_grunge
  • camden184
  • cert15
  • royal_opera_la

Download Grunge posters part 1

  • ry_museum
  • undly_satisfying
  • young_british

Download Grunge posters part 2