Category Archives: Blog

The blog of Aaron Holbrook

Why I changed my Twitter handle, OR the Great Renaming

Firstly, I’m an avid video game player. I love Starcraft (and Starcraft 2), Half-Life and for quite a while I was a dedicated World of Warcraft player. My first character’s name was Tyrun (pronounced Tear (like tears from crying) – Un) which now that I think about it I really liked probably because it’s very close to my real name: Aaron. You know how it goes, you adopt a handle or pseudonym and you start to use that for all your online accounts where you don’t really have any reason to use your real name.

I believe the time to use an online handle has passed as I would like to increase my visibility and allow people to find (the real) me.

And thus I have thrown caution to the wind and have started to brand everything with my name and my name alone: Aaron Holbrook.

I attempted to create a new twitter handle @Aaron_Holbrook, but man starting anew on twitter is just something I don’t really care to do, especially because all the people I care about are already on my @Tyrun stream. So I transitioned @Tyrun to @AaronJHolbrook and shutdown @Aaron_Holbrook. Which is great and which may also be a bit confusing to some people that have grown to be familiar with @Tyrun.

I’m also really glad that Twitter now allows you to change your handle and display name, as it wasn’t always that way and could potentially be confusing to many people.

So yea – there you go, confusion cleared up I hope. Any questions or suggestions feel free to leave me a comment.

Cheers!

David Tufts presents at WordCamp Chicago 2011

WordCamp Chicago 2011

So I just got back home from the first day of Chicago’s WordCamp 2011 held at the lovely Depaul University in downtown Chicago. Man, what a great experience – I just love the inspiration and the idea sharing that goes on at these conferences.

Some highlights of the day were:

  • Dave Tufts’ KickPress WordPress API
  • TJ Stein’s great talk on developing fast & scalable servers
  • Jason McCreary’s talk about developing WordPress on multiple environments (hooray for finally perfecting my workflow! More on this later!)
  • And finally Brian Richards motivational Developing for Success in which he reveals he’s released his development framework Startbox for free!

Also, at the after party I had the opportunity to meet the fantastic Ryan Imel from WP Candy, which was awesome.

All in all a great day – and I’m looking forward to more of the same tomorrow.

Cheers!

get_template_part and Custom Templates

In building the Centegra physician directory back in WordPress 3.0, there was no real way to use WordPress to display out a listing or archive of your custom posts. The temporary workaround solution was a little plugin I found called Simple Custom Post Type Archives‘. It worked well and all I had to do was create a file in the theme’s directory in the format type-custompostslug.php.

However in 3.1 they’ve included much better support for utilizing the already built archives to display a listing of your custom posts.

It took me a little bit of work and digging into using the oh-so-fun get_template_part function, but I believe I’ve uncovered the right way (at least for me, for the time being).

Step 1

You will be using archive.php, so make sure you’re familiar with it. (If you haven’t used it before you should definitely take a look)

In your archive.php, use an if statement to determine what you’re outputting, if you’re outputting your custom post type then take action. (Place above the last else clause)

if ( get_post_type($post) == 'physicians') {

In this case, I’m actually displaying a search form if they land on the physicians page, so this becomes one step more complex – I now have to work in the search.php file.

Step 2 and get_template_part()

Originally, I thought the two parts of get_template_part ( ‘loop’, ‘search’) called the loop.php file then went to a sub-section called search. Actually what happens is it first looks for whatever you list in the first spot (in this case loop). The second area is actually if you’d like to specify a different file – if it exists (loop-search.php) than it calls that, if not it just calls loop.php.

This is insurmountably useful to keep your site logic separate. In this case I want to keep the physician listing separate from the default archive listing.

So I call it:

if ( $_GET['post_type'] == 'physicians') {
  get_template_part( 'loop', 'physician-search-results' );
}

Put that above the original get_template_part( ‘loop’, ‘search’); and turn that into an else statement.

Make your modifications to however you want to display your custom post and you’re done!

Displaying a custom header based on URL

So I recently ran across a situation on Centegra’s website where I had set up our header image to show an image based on the section or area it’s in. This was working fine utilizing a custom get_ID_by_slug(‘slug-of-post’) function I built to get the post ID.

The problem with using custom post types though, is that if you’re displaying an archive listing of the custom post types, you’re unfortunately not able to just test whether or not the loop you’re in is a custom post type (since you’re listing them, you’re one level above).

My current solution I discovered was to test for the permalink or URL. This will only work if you have your permalink structure set up to show /%post-name%/ and if you’re using the Simple Custom Post Type plugin which displays lists of custom post types for you (WordPress unfortunately still has not added this functionality at the time of this posting).

I store the URL in a variable, the string I want to test for (in this case the location custom post type listing) and then use the PHP function strpos (which will return positive if the second string is contained within the first string).

Here’s the code for those interested:

<?php 
$server_uri = $_SERVER['REQUEST_URI'];
$spt_location = "location/";
else if ( $wp-<query_vars["post_type"] == "locations" || strpos($server_uri,$spt_location)  ) { ?>
<img src="&lt;?php bloginfo('stylesheet_directory'); ?&gt; image location here " alt="" /> <?php } ?>

My web design workflow

hifiDesign over on Reddit asked the question of how to use WordPress and SVN (or git in this case). Here is my more extended answer:

I develop primarily on two mac computers, synced via DropBox.

For local development I use MAMP.

I start by locally installing the latest version of WordPress to a clean directory in DropBox. I usually set up a new DB in PhpMyAdmin and get rolling with the new install.

Once the install is up and running it’s time to work on the theme.

I initialize a git repository.

git init

And commit

git addgit commit -m "Initial Commit"

Oh – a sidenote here, I find TextExpander is an awesome helper here. I set up a couple abbreviations to help with the git commands that I use all the time. For example ‘gita’ = ‘git add .’ and ‘gitc’ = ‘git commit -am “%|”.

Once the git repo has been establish it’s time to start developing.

Once I’m happy with development and need to have a live version for testing or for review I set up my live hub and live prime repos. Many thanks to Joe Maller for writing a kickass tutorial on this: http://joemaller.com/990/a-web-focused-git-workflow/

SSH capabilities to your server are a must. If you don’t have them – ask your provider. If they still don’t budge, perhaps it’s time to move to a better host.

After I’ve gotten the bare repo set up in a non-http accessible portion of my server than I install WordPress on the server, get it configured and initialize the ‘prime’ version git repo in the theme folder.

Locally I set up a hub remote to the bare hub repo we created

git remote add hub ssh://111.111.11.111:/home/bare_git_repo.git/

And force push master to the hub

git push -f hub master

Add hub as a remote for prime and force pull to get in sync

git remote add hub /home/bare_git_repo.git
git pull -f hub master

And there you have it. Don’t forget if you’re following along to review Joe Maller’s guide and make sure you set up your post-commit and post-update hooks which allow you to automatically update the prime repo when you push to hub.

Also a word of caution: be aware if you edit files on the server live, you have to SSH in and sync back your other repos or it’ll get out of sync and you’ll have to reset. I’ve been using this setup for a couple months and haven’t once felt the need to fire up a FTP program, live-edit a file and save it and see if it works. Instead I’ve found editing the same file locally, testing locally and then doing a quick

git add .
git commit -am "commit"

is much quicker and easier. Your mileage may vary however.