WordPress for fun & profit, part deux

Last week we extolled the virtues of WordPress: it’s free, it’s super versatile, it’s really easy to use and it’s a fantastic way for a beginning coder to start working in a programming language and learning how to edit complex web applications.

Plus, WordPress hacking is a darn marketable skill. Again, just ask our good friend Zoe.

Today we want to teach you four awesome WordPress tricks that will take you from WordPress zero to WordPress hero in…only a few hours, or days, flat ;)


WordPress Trick #1: Child Themes

One of the best things to do when you are just learning WordPress is to begin by customizing an existing theme.

For example, you might have found a super duper awesome mobile responsive theme that is perfect, except instead of a white background, you want a nice purple one. And instead of orange links you want grey ones, and maybe you want to move a few other elements around.

You could go ahead and just hack into the theme’s files and call it a day. But then a few weeks in, the theme author releases a new version that fixes a bunch of Android bugs, you update your theme, and oh no! all of your changes have disappeared!!

Never fear, child themes are here.

The way child themes work in WordPress is that it creates a parent, the original theme, and a child, which is comprised only of things you want to change about the parent theme.

This way, you can customize the theme to your heart’s content without editing the original theme files, and as an added bonus, you can update to future theme releases without ever worrying about losing your work.

So how do you create a child theme? All you have to do is create a new folder with the same name as the original theme and title it like so:


The only file that’s required in that theme folder is a style.css document. You can then activate your child theme in the WordPress admin and WordPress will know what’s up.

Then whenever you want to customize a file, you can just copy/paste that file into your child theme and it will overwrite the one in your parent theme.

Learn more about child themes.


WordPress Trick #2: Custom Themes

Sometimes, it just isn’t possible to customize a theme and you have to build your own custom theme from scratch.

The best way to do this is to build off a super simple boilerplate theme and just hack that baby into submission. The reason is that there are a bunch of files that you have to have in your theme and it can be time consuming to track ‘em all down.

We recommend starting with the Starkers theme.


WordPress Trick #3: Custom Post Types

So the biggest development in the WordPress platform is that with the release of WordPress 3.0 you could create your own custom post types, meaning that you weren’t beholden to the native WordPress “post” and “page.”

What this did was make it possible to create much more robust content management systems using WordPress.

Adding custom post types is super simple & you can do it by adding just a few lines of code to your functions.php file in your theme:

add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'acme_product', array(
'labels' => array(
'name' => __( 'Products' ),
'singular_name' => __( 'Product' )
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'products'),

That said, the BEST way to do this is to actually create your own plugin so that you can have access to your custom post types regardless of what theme you are using. Check out this blog post from our friends at Team Treehouse about the best way to do this.


WordPress Trick #4: Custom Post Fields

Chances are that if you have some custom post types, you probably are gonna want to have some custom fields associated with those custom post types.

For example, if you create a custom post type called “Books” you might want to have fields for author, title, publication date, publishing house, price, etc.

WordPress makes it super easy to add custom post fields via the custom post fields section of any post form, but the super slick way to do this is to use a plugin called Advanced Custom Post Fields.

Also, should you keep going down the WordPress rabbit hole, we would like to recommend that you familiarize yourself with these three WordPress functions:

1. Function reference/add post meta

add_post_meta($post_id, $meta_key, $meta_value, $unique);

2. Function reference/update post meta 

update_post_meta($post_id, $meta_key, $meta_value, $prev_value);

3. Function reference/get post meta

get_post_meta( $post_id, $key, $single );

What these do is allow you to add, update and get post meta data from anywhere. Let’s say that in addition to using custom post fields in the wp-admin section of your site, you also create a form for the front of your site where people can add and edit information about books. You can take the information typed into the form and add it to the book post, or update an existing book post, using these two post meta functions:

add_post_meta(123, 'title', 'the title entered in the form', true);
update_post_meta(123, 'author', 'the author entered in the form');

You can use get_post_meta() to display any of the metadata that exists by name:

get_post_meta(123, 'title');

So those are our four WordPress tricks. Have you ever worked with the platform? Share your tips & tricks!