For WordPress users, there are certain scenarios when the typical reverse chronological presentation of content is just not enough. I have experimented with different methods of presenting content on 5thirtyone.com each time a redesign is uploaded - from the text-centric to the image heavy version in use right now. With hundreds of WordPress driven blogs being published on a daily basis, it’s difficult to stand out; even more so if you stick to the standard two-column blog layout.
The general consensus or recommendation is for users to either a) invest some time into learning the underlying architecture of WordPress in order to create or modify a theme, or b) invest some money for a one-off custom theme. The latter may not sound too appealing for the beginner or casual blogger, so modifying an existing theme like Grid Focus or October Special might be a good place to start.
How can I create a blog without the typical blog layout?
A typical blog landing page is comprised of noticeably sized chunks of text differentiated by a catchy titles and [possibly] a few inline images.

The typical two-column blog layout works but is used so often that new visitors may slowly blur the lines differentiating your blog from the previous. Sure, you could brighten the page with a few inline post images, but why not step it up a little with WordPress Custom Fields.
What are WordPress Custom Fields?
A WordPress post is comprised of the following:
- Title
- Content - text & images
- Categories
- Tags (if you’re running WordPress 2.3+)
Think of WordPress Custom Fields as extra "containers" of data that can be associated with a post - content that can be called and used within The Loop.
Custom post title with lead graphic background
The first step to setting yourself apart from the rest of the typical title + content blogs is a little style. Adding a photo or image behind a posts title can help to lure a reader into viewing the main excerpt / permalink of your post.

You can achieve a similar effect using WordPress Custom Fields.
First, create the image / photo that you want to use. For the example above, I create a photo of Boo, our Mini Rat Terrier, titled boo-lead-title.gif. Upload the image to your server and save the URI. If you would like the image and post title to span the entire width of your main content column, you’ll want to create a lead image with a width to match that of your main column. In the standard K2 theme included with WordPress, that width is 450px.

Second, compose a new post. Before saving, scroll towards the bottom of the editor pane and add a new Custom Field in the ‘Key’ field. In the example, I created a Custom Field titled lead_image. Paste the previously saved URI in the ‘Value’ field. Save the post - do not publish yet.
Third, open the index.php file in your themes directory and find the line beginning with <?php if (have_posts()) : ?>. If you are using the default theme, the area of the file we will be editing can be found below:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<div class="entry">
<?php the_content('Read the rest of this entry »'); ?>
</div>
<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
</div>
<?php endwhile; ?>
Having previously created a Custom Field called lead_image, we can now call that image from within The Loop. Changes to the above code are in bold below:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<div class=”lead-image-wrapper”>
<h2><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></a></h2>
<?php $image = get_post_meta($post->ID, ‘lead_image’, true); ?>
</div>
<div class=”entry”>
<?php the_content(’Read the rest of this entry »’); ?>
</div>
<p class=”postmetadata”><?php the_tags(’Tags: ‘, ‘, ‘, ‘<br />’); ?> Posted in <?php the_category(’, ‘) ?> | <?php edit_post_link(’Edit’, ”, ‘ | ‘); ?> <?php comments_popup_link(’No Comments »’, ‘1 Comment »’, ‘% Comments »’); ?></p>
</div>
<?php endwhile; ?>
Notice that both the php function and post title are wrapped by a new div with a class lead-image-wrapper. Also notice that the title h2 is loaded before the image.
Fourth, add the following to your style.css.
.lead-image-wrapper { background: #000; position: relative; }
.lead-image-wrapper h2 { font-size: 28px; line-height: 30px; position: absolute; top: 90px; left: 12px; z-index: 1; }
.lead-image-wrapper h2 a { color: #fff; text-decoration: none; }
.lead-image-wrapper img { height: xxxpx; width: xxxpx; }
In order to ensure that the styles are applied, you can either a) remove any previous styles associated with the h2 tags loaded on the index page, or b) place the code at the bottom of the stylesheet overriding any previous code - Cascading Style Sheets.
- A background color is specified for
.lead-image-wrapperin case your image fails to load. Because the title link is white, you want to ensure that the parent element has a background color for readability. - The title link is positioned absolute relative to the parent element
.lead-image-wrapper. Adjust the positioning accordingly for your image. - Always set a height or width for images - make
.lead-image-wrapper imgmatch the dimensions of the lead_image you have uploaded.
Fifth, experiment, experiment, experiment. Part of the learning process is learning by trial and error. Feel free to use the comments for help or feedback.























30 Comments
Quote
So that’s what the custom field section is for when making a post…
Very helpful tutorial Derek, I always wondered how you made your landing page with dynamic images as a background with the title on top. Does that also mean you have two loops going and upload two images per post (a large one if it’s newest and a smaller one when it becomes older)?
Quote
Thanks Derek! I’ll keep this im mind when I make a new theme.
Quote
Nice solution Derek, thanks for sharing it. But this really makes me wish that there was an easy way raise the prominence of a custom field in the backend of WP. If WP has one issue that I’d like to fix it’s that adding new content fields to posts always involves the inelegant solution of custom fields, which are usually down below “the fold” when composing a post.
Quote
Yup. I have a few different loops running on the front pages - recent posts also have a few custom fields associated with them to display different sized images.
Quote
Wow, I didn’t know about this one!
Thanks Derek for letting me learn something new today about wordpress
Quote
If there is a plugin to customize the WordPress Dashboard, it is likely a plugin could help someone customize the post editor view.
Quote
I did not know of a good use for that until now. Thanks.
Quote
Just found out about Clutter Free. A plugin that lets you customize what is visible in the WordPress post editor page.
Quote
Derek, those are some interesting plugins. I’m rather impressed with Clutter Free; though it’s not exactly what I want, it’s pretty interesting. What I would like to see is a field right under the Title field for the image address, so that it would prominent and hard to forget about rather then down at the bottom in the Custom Fields section.
I’ve done some looking into this, but so far haven’t figured out exactly how to do it. It’s slow going: my PHP is remedial at best, and my experience with WP’s backend and plugin creation is non-existent. I’ll have to spend some time looking at both of these plugins, they can probably teach me a thing or two.
Quote
oh yea,, thank for this Derek, hey can you tell again in another post how you make the recent posts like your, i hope so, thanks again
Quote
Great article Derek. I’ve also begun tapping the custom field well, so to speak. I use it to power the photo section of my site. I house Flickr images and links rather than uploading pictures to Flickr and my blog or using a third party plugin (none of them did what I wanted). I’ve really been impressed by what you can accomplish with custom fields.
Quote
Hi Derek,
Thanks again for an awsum and very helpful post!
I have followed your guide but still having trouble, the code seems to be right but the image doesnt seem to be displaying at all…
here is my code, I haven’t modified the css code at present except for entering the image dimensions, any ideas?
<div class=”blog2 fix” id=”post-”>
<a href=”" rel=”bookmark” title=”Permanent Link to “>
ID, ‘lead_image’, true); ?>
Stu
Quote
This lead-image custom field just doesn’t seem to do anything.
The image isn’t displayed, and it only, for the most part… busts up any theme i apply it to.
Even the default theme.
Is there a specific version of wordpress or other elements in play??
I poked around around in your forum… doesn’t seem to be much info their on the matter either.
looks cool on your site…. would love to display posts in a image based grid.
Quote
I too am having trouble getting this to work at all. I don’t have a need to place text over a graphic, I simply need to be able to place an image relating to my post that appears above the post title and post content.
I think this can only be achieved by making a custom field and declaring an image for it as has been described in this article. However, after declaring my custom field and placing the PHP snippet into the PHP file, the image simply refuses to show up.
Quote
Do you know how to implement the “read more…” function on blog posts? This lets users read the first paragraphs and limits space by long blog posts…
-d
Quote
To anyone who posted above me..
There are two things going on here.
First, check your quotes when you paste the code into your index template, mine were copied wrong. If you want a plain text solution of what your code should look like, check here:
http://snipplr.com/view/4867.6518/
Also, he forgot to echo out the image
For a complete working code snip check here:
http://snipplr.com/view/4867.6519/
Quote
whoah there, i just noticed: “In the standard K2 theme included with WordPress, …” i just downloaded WP 2.3.3 and it doesn’t use K2. does Derek know something we don’t?
Quote
I’ve recently discovered the More Fields and Fresh Post plugins, either of which might help you do what you want.
Quote
Even though I’m subscribed to your feed, I didn’t read this post until now! Its a good post, very informative, but as others have noticed, I think you are missing your img tag on the custom field.
I recently wrote about creating something similar, but where the posts use a crossfading script to rotate through them.
I also made my image clickable by wrapping the custom field in an a and img tag, so that clicking the image takes you to the post as well. This seems more natural to me, after all, we’re using the images to pull people in right?
You can check out my code here: http://epicalex.com/creating-dynamic-crossfading-recent-posts/
Alex
Quote
Hi Derek,
Your theme made me decide to move to independent-hosted WP. It is the best thing I have seen so far in my 7 months in the blogosphere and two months of blogging. So cooool. I know very little coding and html. My bgrd is in healthcare. I managed to do all the uploading and installations, but I keep getting this error when I try to use any of the sidebar items. Also trying to widgetize the theme has been impossible for me. Please help me. Below is the error code:
Parse error: parse error, unexpected T_STRING in /home//wp-content/themes/unstandard/index.php on line 13
These are the first few lines of my index.php:
<div class=”post” id=”post-”>
<a href=”” rel=”bookmark” title=”Permanent Link to ”>
ID, ‘lead_image’, true); ?>
<?php the_tags(’Tags: ‘, ‘, ‘, ‘’); ?> Posted in |
Please be kind enough to edit this post as I know your blog is not a forum and should not have this kind of code. Forgive me.
Quote
Thanks. That is sorted. I screwed something up when I was tweaking around. I deleted and re-installed it. That aspect is fine now. Are you soon to release the widgetized version. I am unable to do it even with all the guidance (not much) on the Automattic website. Or does anyone know of any plugin that does it automatically?Thanks.
Incoming Links
Leave a Reply