Tuesday, June 26th, 2007
at 9:16am
Previously, I briefly illustrated how using a home.php file can allow you to build a custom layout to your WordPress blog’s home page. However, I didn’t really document it well enough for the casual WP user to implement by himself. For the unknowing of my readers, here is a guide to using my (really Rudd-O’s) discovery on your site.
If you already understand the concepts behind this, skip to the download link.
Let’s take a look at Rudd-O’s code again. Try to figure out what it’s doing:
1: <?php $homepage = get_settings('siteurl')."/home/";
2: global $wp;
3: $wp_received_argument = false;
4: foreach ($wp->query_vars as $k=>$v) if ($v) $wp_received_argument = true;
5: if ($wp_received_argument) require(TEMPLATEPATH . "/index.php");
6: else { wp_redirect($homepage);
7: exit(); } ?>
Line 1 gets the address of the blog and adds what we would use to access a static page with a slug of ‘home’.
Line 2 brings in the $wp object, which allows us to figure out if there are any parameters in the URL that we need to work with.
Line 3 sets a simple boolean value of ‘false’ to a variable that we will use to determine if we have recieved any parameters.
Line 4 looks at the $wp object and asks it if there are any parameters. If it finds any, then we set $wp_received_argument to ‘true’, and we will use that in the next line.
Line 5 is where the magic happens. If we have parameters, like the page number variable, then we will load the regular index.php template which will show you the normal blog page. Otherwise, we will continue to line 6 and 7.
Line 6 will run if we don’t have any parameters, which means that we want to show our special home page. We will send a redirect to the browser telling it to go to our static page. Then we quit running this page, since there is nothing more to do anyway.
This is a relatively simple concept. Rudd-O mentioned in his original article that one should add a link to /[wp-root]/page/1 somewhere, like in the header along with the page links for example. What that will do is give WordPress the parameters we need to have the blog listing shown. If you need help adding this link, leave a comment below.
Here’s the fun part. My hacks to Rudd-O’s code will replace the redirection of the original code. All HTML and PHP content is placed within home.php. Now that we are including our content in a straight-out PHP file, and not going back to the database to retrieve a page (via the WP Loop), you can even add a real mini-loop to your front page! You can do whatever layout you want with home.php now. (See my home page, which has the mini-loop, a list of categories, and my Flickr photostream, for an example).
Now that we understand what Rudd-O’s code accomplishes, it’s up to you to use your imagination. Until recently, my email that came upon request included some basic instructions, which read something like this:
Attached is a well-commented version of home.php. Use it to set up your custom layout, but don’t upload it yet.
In order for this to look and function properly on your site, you will need to adapt it to your theme. You will have to make the portion of home.php before my table-based layout look like the code in index.php from the top of the file to just before the loop, and from just past the loop until the end of the template. Remember to close the else statement with a right curly bracket.
Also, you will need to add the /page/1 (or ?paged=1 if you aren’t using pretty permalinks) link to the page list in header.php, which should include code to dynamically change the highlighting of the Home and Blog links.
For those basically familiar with PHP, HTML and some of the simpler CSS concepts, adapting the sample home.php file I am providing should be somewhat easy. If you don’t have such keen skills, you can review the W3Schools’ tutorials on HTML and PHP for a bit of help. (Sorry folks, these days I can’t handle doing the editing for everyone, although I wish I could.)
If you are convinced that you want a home page with a custom layout for your WordPress blog, I have provided an older version of my layout, plus all of the associated logic basedon Rudd-O’s code. As noted above, you will have and want to do lots of tweaking with it to make it look good, so grab the download below, and hack away.
Download sample home.php layout »
Saturday, February 24th, 2007
at 10:09pm
Trackbacks are one of those blogging features that some beginners just don’t get (I was there – trackbacks have only made sense to me recently). The truth is that they are very simple to understand.

Think of trackbacks as comments that are posted by your blogging tool, rather than your own self-determination. To use a rather crude comparison, they are similar to video responses on YouTube. Someone makes a video. You think that you can add to that video. you make a video, and it shows up under the existing video.
Same concept with trackbacks. You find a blog post on someone’s blog that you think is interesting. You write about it on your blog, and leave a trackback in the process. The whole nine yards:
- You read a blog post, and you like it.
- You write a post on your blog about it. This could possibly be an “Aside” post.
- While posting, you paste the address of the post you are commenting on in a special field on your post editing screen. With WordPress-powered blogs, the trackback address of posts will be the post address, followed by “trackback/” (ex. http://www.mysite.com/blog/2007/01/02/my-first-post/trackback/).
- Upon the publishing of your post from your blog, their blog is notified by your blog, and a link to your new blog post is made on their blog.
To make this all fair, you should remember to include a link to their post in your post if your post is not specifically about their post, in which case you may not remember to leave a link. That way, the network between you and them is built, and you two have formed a “micro-relationship” of sorts.
You should also leave comments on blogs regularly, but that’s another topic. Following these tips will help you build your blogging future, giving your blog increased exposure. But remember the main rule for any Web site: Content is king.
Sunday, February 11th, 2007
at 8:47pm
Recently, I’ve been observing a new form of spam on my blog. It is coming in the form of vague registrations, with email addresses including Russian domains and strange user IDs. For now, it’s not too bad, so I won’t take serious action. If things do heat up, I’ll look into ways to effectively block spammers from clogging up my users table.
Friday, January 19th, 2007
at 3:44pm
Quick Note: If you are looking for the source, find it here.
With WordPress, there have been so many attempts to make the best static front page. Most variations have included plugins that change the default behavior of the home page to display a pre-selected WordPress page. However, the Turbocharged blog showcases a new technique that uses a theme’s home.php template, and even allows you to add pure PHP code to it. Rudd-O’s solution Continue reading »
Wednesday, January 17th, 2007
at 7:18pm
While including one slightly family-unfriendly line in his lyrics, Devin made up a pretty corny music video themed around WordPress. Talking in a southern accent, he highlights the main advantages of WordPress, and adds a spin of comedy.
Sunday, January 14th, 2007
at 8:36pm
We all know that WordPress is pretty much the best (or at least best open-source) blogging platform today. It costs you practically nothing to use it (on WordPress.com, it’s absolutely free), and all you need to start blogging, not counting the techy stuff, is a few interesting thoughts and a passion for sharing your mind. However, for those who want to take the path less taken, and write their own blogging tool, it’s almost impossible to do so, as Computer Guru points out. I suppose that only the most inventive and creative programmer/designer can rival WordPress.
Saturday, January 13th, 2007
at 11:49pm
Although I do have the absolutely wonderful and I-can’t live-without-it Askimet plugin installed here, I still look through the messages it catches every few days. What’s worse than having to waste time even looking at them is trying to ignore what’s in them. Various prescription drugs (I’m keeping things G-rated over here), and links to what I will leave as explicit videos litter the Askimet Spam page litter my screen every time I look at it.
Eventually, someone is going to (or I will) say enough is enough, and just get rid of comments once and for all. We all hate weeding through spam emails (which affect a much greater majority of people than comment spam does), so why should we feel the smame about comments?
Wednesday, January 10th, 2007
at 9:57pm
cre8d design has written a pretty good list of resources for WordPress theme developement. They include one of my personal favorites, W3Schools.com, which has a lot of useful Web tutorials.