So you ended up here, eh? Well hello! My name is Stu Greenham, and this is my blog!
I'm a 24 year old Apple loving, Magners drinking Web Designer from Hull, England. close

Working with Custom Fields in WP

Every one who uses WordPress for there blog will have no doubt at some point noticed the section labelled ‘Custom Fields’. Now be honest, how many of you use this feature on your Website? or how many of you at least understand what it does? The feature is infact very handy and with a few simple steps, it can really make your WP Theme stand out, but there are many who don’t take advantage of it!

Hopefully if your reading this you have some understanding of how WordPress works, and fingers crossed you are aware of the WP Loop that pulls your posts to display on your site. If you are not familier with the Loop then this page will be very usefull to you in your quest to conquer WordPress (http://codex.wordpress.org/The_LoopClick).

You can define a custom field for each post and set its value to be anything, for example, a URL of an image you want to display, a URL of a site you wish to link to, or just some random text. Okay, this may not make sense yet, but the easiest way to explain, is to show you how I use the Custom Fields on Self Conclusion.

So first things first, where do I use these ‘Custom Fields’ on my site? Well when you visited my blog you will have noticed the featured section of at the top of the page just below the Twitter section. This currently displays three posts, along with an image, and a short excerpt of what it contains. Custom Fields are used here to display the Image for that particular post. You may be wondering why can’t I just call the images I want to display manually and change them as and when I write a new feature post? Well this method isn’t as effecient removes some of the dynamicness (not sure if that is a word by the way) of your site. Lets face it, we use WP to allow us to manage our content better!

How do we do it then Stu? Well it is really easy, first you need to assign a custom field, in my case a link to a thumbnail image that I want to display above the post title and excerpt.

In the Custom Field section you have two options that require your attention, the Key and the Value. The Key can be anything, but its a good idea to keep it fairly simple as you need to call it later on, try call it something relevant. Think of the Key value as a variable name, so for this example I will call it post_image because suprise suprise I am going to be using it to display the post image! (clever I know). In the Value field you need to put whatever it is you want to display, in this example a URL which links to an image. Once you have filled in both parts, click on ‘Add Custom Field’.

Custom Fields in Admin Area

Next we need to ammend the WP loop to include this new field on your site. Before I implemented an image to my feature posts, I just had the Loop pulling the Title and the Excerpt, and my code looked like this…

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
 
<div class="feature">
 
<p class="feature-title"><a href="<?php the_permalink() ?>" rel="bookmark" 
title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></p>	
 
<p class="feature-preview"><?php the_excerpt(); ?></p>
 
</div>
 
<?php endwhile; ?>

We need to add a bit of code for the custom field. The key part is the get_post_meta part, because this calls the custom field and outputs what you set in the WP Admin area, in this case it will output http://selfconclusion.co.uk/images/posts/image1.jpg. Notice the post_image, this needs to be set to the name of your custom field which you should have set earlier. Finally, we need to place the code around an image src tag to ensure the image is displayed on the page, see below…

<img src="<?php echo get_post_meta($post->ID, "post_image", true); ?>" 
alt="Permanent Link to <?php the_title(); ?>" />

Very simple indeed! Now when I add this bit of code into my WP Loop you get the following…

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
 
<div class="feature">
 
<img src="<?php echo get_post_meta($post->ID, "post_image", true); ?>" 
alt="Permanent Link to <?php the_title(); ?>" />
 
<p class="feature-title"><a href="<?php the_permalink() ?>" rel="bookmark" 
title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></p>	
 
<p class="feature-preview"><?php the_excerpt(); ?></p>
 
</div>
 
<?php endwhile; ?>

Here is what you see on screen in my case…

Well thats about it for now, but let me know if this has come in handy for anyone. It really is a simple process and so easy to implement on your website. If you have used custom fields on your WordPress site then leave a link in the comments.

Guest Post on ImJustCreative.com

Yesterday, my very first Guest Post went live! The post titled “(Nerd)Press The Nerdiest WordPress Theme Around” talks about the progression of my first WP theme I am currently developing. I focus the post on several features as well as where I am hoping to go with it.

I just wanted to say thanks to Graham Smith of ImJustCreative.com, for been the legend that he is and allowing me to put some content up on his site, as well as the promoting he has been doing for the post too!. Check it out for yourself at http://imjustcreative.com and let me know what you think :)

Alternatively spread the word using any of the following…

Thanks to all who have already started spreading and/or leaving feedback! So far I’ve had good comments! If you have any things you think would go well on (Nerd)Press let me know by adding me on Twitter (@stugreenham)

Self Conlusion WP Plugins (Part. 1)

Following on from my last few posts on WordPress, I thought I would talk about the various Plugins that I frequently use, and imparticular, the Plugins that are built into Self Conclusion, as I have several sections which import information from various social sites such as Last.FM, Delicious and Flickr.

Akismet

I will start with the Self Conclusion Plugins, I just briefly want to mention the first plugin, which is actually one that comes built into WordPress. The Akismet plugin is often missed by alot of newcomers to WordPress but it is infact very useful for filtering out the dreaded SPAM comments. Once activated, you are required to register for a WordPress.com account, so you can retreive an API Key which will need to be entered into the Akismet Configuration page.

Akismet WP Plugin

The image above is just a snippet from my Akismet page and you can see that two messages there are clearly junk, and Akismet has marked them as Spam, meaning I don’t have to deal with them.

The next set of plugins are by Ricardo González over at Rick’s HideOut. They deal with Twitter, Last.FM and Delicious Feeds, and require minimal setup.

Twitter Plugin for WordPress

I use this plugin to display the large ‘Twitter’ text at the top on my Homepage. The plugin doesn’t deal with the formatting of this text, it simply grabs it from your Twitter account and displays it on your blog. To install, download the plugin from the link below and upload it to your WordPress Plugins directory (eg. http://www.domainname.com/wp-content/plugins). Now go to your WP Admin area and activate the Plugin. To Display your Twitter status, simply insert the following code between a set of PHP Tags into your page, replacing the username:

twitter_messages('username');

This ofcourse is only the very minimal settings on this plugin, as there are many attributes you can tweak which can be found on the Plugin page here http://rick.jinlabs.com/code/twitter/.

Last.FM for WordPress

Similar process to the Twitter plugin, but this displays the recent tracks Scrobbled on your Last.FM account, in my code, I set it to display the latest 7 tracks. To install, download the plugin from the link below and upload it to your WordPress Plugins directory (eg. http://www.domainname.com/wp-content/plugins). Now go to your WP Admin area and activate the Plugin. Inserting it into your blog couldn’t be easier (Don’t forget the PHP Tags):

lastfm_tracks('username');

Again, there are many other attributes which can be set such as how many tracks to display. These can be found here http://rick.jinlabs.com/code/lastfm/.

Delicious for WordPress

The final plugin I want to mention from Ricardo is ‘Delicious for WordPress’. I won’t go into to much detail because the process of setting it up and building it into your blog is exactly the same as the previous two plugins, but using the following code (again put this code between a set of PHP tags):

delicious_bookmarks('username');

Like the previous two Plugins, the code above only deals with the default values, to tweak it further, visit the following page http://rick.jinlabs.com/code/delicious/.

More To Follow….

Right, thats it for this post, be sure to keep checking for Part 2 when I talk about the other Plugins I use on Self Conclusion, and other more favoured Plugins I have used in the past. I’d love to hear about any plugins you guys use or if you also use some of the ones I have mentioned and what you think of them.

WordPress .XML Test Data Import

If you have read any of my previous posts about the mighty WordPress, then you might be able to work out I am a big fan! Very true indeed! Infact 99% of the sites I have done use it. When creating a design I won’t build it into WordPress from the start, main reason is that I can concentrate fully on the HTML/CSS code and not have to worry about PHP loops, etc. Much simpler!

I use Lorem Ipsum to generate text to bulk out my design and give me a more realistic feel of how it will look live, which is great. When I come to integrating the site into the WordPress CMS I end up left with a kind of ‘blank canvas’ containing just the default ‘Hello World’ post! Having to continuously create fake posts/categories/tags/comments to check it all works within WP is well, Very Frustrating :(

For anyone else who has the same problem as me, this ones for you. Download the .XML linked below and import this into your WordPress installation and problem is sorted, the .XML will import the following:

  • 5 Pages, with full content
  • 10 Posts, with content, including Tags, Categories and Excerpt
  • 21 Unique Tags
  • 11 Unique Categories
  • 10 Unique Comments, including several from the ‘Tester’ user (Administrator)
  • 7 Default Links
  • 1 Post (under category ‘Bullet List’) contains a Bullet List
  • 1 Post (under category ‘Numbered List’) contains a Numbered List
  • Various Lengths on each posts content and title

If you are not familiar with Importing an .XML file into Wordpress then follow this quick guide (based on the 2.6 version of WP)

  1. Unzip the .XML from the downloaded archive
  2. Log into your WP administration area (http://www.sitename/wp-admin)
  3. Select Manage from the main menu
  4. From the Manage sub-menu, select Import
  5. You will be provided with a list of Blog types you wish to import from, select WordPress from the bottom of the list
  6. Next select Browse
  7. Locate to the .XML you downloaded from the link below, select Okay
  8. Finally, select Upload File and Import

Any problems let me know, but should be fairly straight forward! Finally here is the download link:

Download: WordPress XML Import | Help spread this post by Digging It

(Nerd)Press - My Own WP Theme

I’ve been saying to myself for a year or so now that I would develop my own WordPress theme to distribute on the web. Well, I recently have had my tonsels out which has meant lots of time has been spent either in bed, or lounging around the house (be it in pain but still). The other day I decided I finally started, and three days in its going really well!

The name of my first WordPress theme is (Nerd)Press, inspired by the TV show Chuck which I was watching at the time. So far I have working index and single-post pages, as well as working navigation, sidebar and footer sections, and finally a hugggee search bar panning 800+ pixels but looks very neat. The searchbar itself slides down using the ever popular jQuery which I am loving! I have also registered http://nerdpress.co.uk for when its ready to go public, at present there is only a centered logo up there but I plan on having an Email submission box up soon for anyone wanting to receive updates on my progress.

Thats about it for now, but here is a screenshot of what I have so far.

Selfconclusion redesign :)

Well, I finally did it! Selfconclusion has a new look, and I am very happy with the way it has come out. I’ve been wanting to do it for ages now but after several unsuccessful attempts, I was beginning to think I would never get it done. Anyway’s thats the past now and heres the present. The site is not 100% completed and there are a few bugs, The archive page isn’t done yet but the single post page is.

As you may already be aware, I design my sites around Wordpress, which if your not familiar with, you need to start getting familiar with, as it is a very handy CMS that allows you to fully customize and extend using various plugins. The old site was built around Wordpress 2.1, and for the new look I decided to upgrade to 2.6 which I am finding so much better! Wordpress is totally free, and very simple to setup. In fact, your Webhosting most likely has it ready to install straight from your control panel, which makes things even easier!

I need to thank Rick from Rick’s HideOut for his Wordpress Plugins that have been implemented in the new design, these plugins are ‘Twitter for Wordpress’, ‘Last.fm for Wordpress’ and ‘Del.icio.us for Wordpress’ which are all very simple but handy plugins for displaying content from external sites straight to your Wordpress Blog.

I won’t rant on anymore, but I hope you like my new site, I have also redesigned my Webfolio which is now up and running, the address is http://stugreenham.com. Below is a before shot of Selfconclusion, I hope you agree it looks tonnes better!

Let me know what you think of the new look….

Archives for the ‘WordPress’ Category