aside

For a while now I have commented on the fact I would like need to get a new PC and upgrade at the same time. The one I currently have runs Windows XP, only has 512MB of RAM (yeah OMG you’re all saying), and had a number of problems with it! — So I just went ahead and ordered myself a new Dell Inspiron 580 and a 21.5″ monitor! :D

post

WordPress 3.1 Introduces Custom Post Type Archives

While development on WordPress 3.1 is still ongoing and we’ll probably not see the final release until nearer the end of the year, I thought I’d let you know about a cool new addition to Custom Post Types that Andrew Nacin (Core Developer) worked on!

Little Background Info

Around 5 months ago #13818 was opened requesting an Index/Archive option for Custom Post Types because the way WordPress works meant that /post-type/ would just 404 on you although /post-type/wordpress-rocks/ worked just fine.

Similar could be said about Custom Taxonomies and how they function which I brought up back in February on the WP-Hackers Mailing List – I don’t think I was popular in the community that month for sure? While it’d be a nice addition I know many would like (and shut me up) I have been informed more than once it’ll not happen!

Now For Some Code

If you’re new to Custom Post Types and the register_post_type(); function then make sure to check out an in-depth article Justin Tadlock wrote on the subject, I recommend you read it anyway! :)

In our functions.php file lets setup a basic Projects Post Type with the Archive active.

add_action( 'init', 'mcw_projects_post_type' );

function mcw_projects_post_type() {

	register_post_type( 'projects', array(
		'labels' => array(
			'name' => __('Projects'),
			'singular_name' => __('Project')
			),
		'public' => true,
		'show_ui' => true,
		'rewrite' => array(
			'slug' => 'project',
			'with_front' => false
			),
		'has_archive' => true
	) );

}

We’re looking at the has_archive argument which has been set to true which will turn on the Archive for this particular Custom Post Type, normally it would default to false though! — But we can take that a step further because when it’s set to true it’ll fallback to the value in the slug argument. So here that would make it site.com/project/ which just wouldn’t look quite right!

'has_archive' => 'projects'

All we did was substitute true with projects which therefore shows site.com/projects/ as being home instead. Now we know we can do that, we can do all sorts of things (get creative), we don’t need to keep it in line with our Projects Post Type.

'has_archive' => 'work'

Thinking outside-the-box gives you site.com/work/ which is different, the option is yours!

What Else Might I Need To Know

A new archive-{$post_type}.php template was introduced although it will fallback to archive.php if it can’t find the appropriate template for the job. So for our Projects Post Type, as projects happens to be the value we used for the Custom Post Type, we’d call our template archive-projects.php — Similar to if we used the portfolio value for a Portfolio Post Type we’d end up calling our template archive-portfolio.php and so on.

If you get a 404 error when trying to view the Custom Post Type Archive then simply visit Settings > Permalink which will flush your rewrite rules for you, it’s as simple as that, and there we have it!

aside

I’m a really BIG fan of the stuff Rally Driver Ken Block does then sticks on YouTube, and his latest video is just as good (if not better) to watch! Always good to see Top Gear linking us up with that kind of stuff!

aside

For a while now I have commented on my PC doing stuff that I never asked it to, and in general just causing more problems than good, of which if finally stopped working last night! :( Which for people who use it for day-to-day tasks like myself, I wouldn’t like to think how much time I have wasted doing even the simplest of tasks? — Not to mention when it comes down to the specification, you’re speaking to the wrong guy here, I don’t know where to start (with a Core i7 Processor) or what I’m looking for?

aside

Anyone looking to get into developing a Plugin for WordPress (like myself) will have to look no further after the announcement made from Ozh Richard, Brad Williams and Justin Tadlock! They’re going to be writing a book on the subject, and hopefully in March 2011 “Professional WordPress Plugin Development” will be released for everyone to read and learn from! #plugindevbook

aside

On taking a few weeks out while work continued on the 3.org Project, the WordPress Development Team are now back into the swing of things with a post from Jane Wells yesterday asking anyone with feature ideas for 3.1 to comment! — Already spotted a handful I’d like to see added but the plan is to discuss as many of them as possible at the Developer Chat on Thursday night!

aside

It was announced by Matt Mullenweg after Leland Fiegel of ThemeLab.com asked the question when he found out a previous design on http://ma.tt/ had been turned into a Child Theme for Twenty Ten which is the new default theme included in WordPress!

aside

Can you believe the photo Matt Mullenweg took when he was caught speeding?

aside

I found it odd to think a whole year had passed since Page.ly was first launched by Joshua and Sally Strebel (and their little elves) but time flies when you’re having fun! - So to help Page.ly celebrate in style you’ve been invited to the Page.ly Birthday Bash! :)

aside

I think this has to be the best goal celebration in football ever?! While it only lasts 22 seconds on YouTube, it really is one of the funniest things I have seen in a while! :) … Tell me you didn’t find it funny?