Default post thumbnails in WordPress

There is regular discussion within the WordPress user community on certain common encounters developers have when creating themes and plugins. One such discussion is around post thumbnails 1 and, more specifically, how to specify a default thumbnail. After reading a few discussions around this, I thought I’d share my take on things.

There are a myriad of methods to achieve this. Some developers do conditional checks in their code to see if an entry has an image assigned to it. This is the most common method of applying a default thumbnail. If the entry doesn’t have a thumbnail, display a default image. That’s pretty straight forward. That being said, this method requires extra logic on the frontend of your website, which may not always be clean/necessary.

Continue reading

Filtering the Options API in WordPress

The Options API in WordPress is one of the many APIs we all use every day when developing with WordPress. A quick use of get_option() is not uncommon. What if you could filter those options? You can.

Adding filters in WordPress is also a common practice. Combining this with the Options API can allow for, as an example, changing an option when in preview mode without committing to the change.

In the “Magazine” template in the Canvas theme by WooThemes, for example, WooTumblog “image” and “video” posts are aware when they are present in the magazine-style grid. This is an example of filtering the Options API.

Continue reading

Matty Theme QuickSwitch featured on The Sweet Plugin of the Day

One thing I enjoy almost as much as developing with WordPress is reading about WordPress development and the goings-on within the WordPress community. WPCandy, a website I’ve written a few posts for, is my main go-to resource for community news and current happenings within the WordPress community.

Ryan, the editor at WPCandy, broadcasts a video podcast called “The Sweet Plugin of the Day”, where he reviews a plugin that he finds useful and/or interesting. Matty Theme QuickSwitch, a plugin I recently released to make quick switching between WordPress themes easier, was recently featured on “The Sweet Plugin”.

Continue reading

My (updated) WordPress Plugins Toolbox

Blue WordPress logo, courtesy year, I wrote about my WordPress plugins toolbox, a series of WordPress plugins I find myself using day in and day out. Since then, the list has grown and developed further to adapt to my varying needs when constructing WordPress-driven projects. Below is an updated list of the plugins I find myself using almost always, in addition to the custom tweaks and widgets I’ve written to accommodate my needs within WordPress. Continue reading

Javascript and WordPress – The Definitive Guide

Using custom JavaScript code in a WordPress theme or plugin is, in many cases, a given. Fortunately, WordPress comes bundled with a selection of popular Javascript libraries (jQuery, Prototype and others) for use with your plugins and themes. Many users, however, simply write the `<script>` tags in the header.php file of their theme or as part of a function in their plugin that is run in the header of the theme being used. This is a potential problem area that can have you, the developer, sitting for ages looking at your code and wondering why plugin `X` isn’t working correctly when theme `Y` is active. This guide aims to provide an understanding of how to correctly enqueue Javascript in WordPress and how to avoid potential Javascript conflicts.

Okay, what are we doing here?

We’re going to enqueue the Javascript files, used by our WordPress plugin or theme, using the correct method and the wp_enqueue_script()function. We will be adding an action to the wp_print_scripts() action and, inside a function within our theme or plugin, running the wp_enqueue_script() function. We will also be including the Javascript in the administration area only, creating dependencies between our various custom Javascript files and enqueuing the scripts on only a specific page in the administration area. Continue reading

Child plugins in WordPress. An idea?

I’ve been reading a lot over the past few months about child themes in WordPress and how users have found them to be an invaluable resource when creating WordPress themes.

What’s this “child theme” thing?

For those unfamiliar with the concept, the way I’d explain it is as follows:

A user chooses a WordPress theme (or theme framework) which they would like to customise. They then create a new theme with only the files required for the customisation. The main change comes in the style.css file where the theme details are specified. The line “Template” is added to the theme details, which then specifies the folder name of the main theme (chosen above). An example block would like like this:
Continue reading

Custom URL rewrites in WordPress – A Getting Started Guide

I’ve been tweeting quite a bit recently about custom URL rewrites in WordPress. After a few hours of trial and error, I’ve managed to get my specific custom URL rewrites working. After reading through several tutorials online (the majority of which used the same examples to explain only a portion the information I was looking for), here’s my tutorial- a getting started guide to Custom URL rewrites in WordPress.

The process

So, what exactly are we doing here? To put things in point form, this is the process:

  1. Create custom rewrite rules
  2. Add our new variables to the public_query_vars array
  3. Flush (and thus, regenerate) all WordPress rewrite rules
  4. Add our functions from steps 1, 2 and 3 into WordPress via actions and filters

Right, so lets get down to it then. Continue reading

WordPress theme features: What would you like to see?

I’ve been rolling the idea around in my head for a while now to create a WordPress theme, packed with all the features I find myself repeating on each project, as well as some new, useful features… and maybe a few whacky ones as well.

Yesterday, I jotted down a list of features I’d like to potentially include in this theme… some useful, some for repetitive tasks and some just weird and whacky. My question to you all is, what features would you like to see?

They can be any of the above- minimise repetitive tasks, new and useful or just plain weird and whacky. Lets have it guys. What features would you like to see in a WordPress theme?

Continue reading

A few guidelines for WordPress plugin development

The WordPress plugin API is vast and powerful. It allows developers to essentially hook code into almost any area of the WordPress system without modifying the core files at all. It also allows for the creation of standalone plugins that work within the WordPress system but do not hook into the core modules.

Over the last few weeks, WordPress plugin development has become one of my favourite things to do. I find it exciting to be able to create functionality, incorporate it seemlessly into the WordPress system and see it work smoothly with the other modules. While plugin development for WordPress is incredibly powerful, it also carries with it a few areas where people commonly stumble over and potentially lose interest in their code… which could be the next big thing. Here are a few guidelines I’ve picked up in order to step over the stumbling blocks.
Continue reading

My WordPress plugins toolbox

Hey everyone,
Just thought I’d post a list of my most regularly installed WordPress plugins and why they are installed on virtually every WordPress installation I do. If there are any plugins I haven’t listed that should be, please let me know in the comments. 🙂

1. Maintenance Mode

This plugin is truly awesome. It allows the developer and end-user to test the WordPress installation thoroughly, on the server where it will eventually be hosted, without displaying it to the world. It also allows the user to, as it says in the title, take the website down for maintenance at any stage and leave a message for users letting them know of the downtime.
Continue reading