Tim Yang’s Weblog


Howto: Customising the description metatag to the title of each post in Wordpress

Filed under: Howto, Wordpress — Tim Yang @ 12:00 am

Instead of having a set of standard metatags across all the pages of my blog, I wanted to customise the description metatag of each post to the title of the post and the keywords metatag to the categories of each post. I thought I saw a plugin that did this, but when I looked again, I couldn’t find it. Because I’m reading up on Wordpress Template Tags right now, it made sense for me to try do something different with them. So out comes the PHP for Dummies manual. I succeeded (partially) in my goal. If you check the description metatag of each post, they are all customised while the homepage has the standard blog name and description that’s set in the admin interface. But I failed in the categories as keywords because the category template tags don’t work outside of the Loop.

Here’s the code I used. Just copy the description metatag part and paste it between your head tag to achieve the result.

	<meta name="description" content="<?php if ( is_single() ) {
		single_post_title('', true);
	} else {
		bloginfo('name'); echo " - "; bloginfo('description');
	?>" />


Howto: Generating a list of earlier posts in Wordpress

Filed under: Howto, Wordpress — Tim Yang @ 4:41 pm

I had this feature in my earlier weblog. I had ten posts on the home page and I wanted to show in the sidebar a list of the ten posts that pre-dated the ones on the homepage. You can see the unstyled list on the sidebar right now. I used the get_posts function that comes in Wordpress. Although the_date function is supposed to work only within The Loop, somehow it works here. Here’s the code I used.

<ul id="earlierposts">
$posts = get_posts('numberposts=10&offset=10&order=ASC');
foreach ($posts as $post) : start_wp();
echo "<li><a href="";
the_permalink(); echo "">";
the_title('', '', true);
the_date('j M','</a> <em>','</em></li>');


Reference guide of Wordpress template tags

Filed under: Blogging, Wordpress — Tim Yang @ 12:49 pm

A few months ago, Kafkaesquí found that like myself the Wordpress Codex was missing a major section — a reference guide to template tags, like the ones in the addendum of most programming manuals. Luckily Kafkaesquí made the effort to rectify that mistake and published his list for everyone. Thanks, Kafkaesquí!

WordPress Template Tags (1.5) reference


Wordpress taxonomy

Filed under: Wordpress — Tim Yang @ 4:31 pm

The ad hoc nature of tags appeals to me more than categories as a taxonomy system. I’d rather not have my posts conform to a pre-set list of pigeon-holes, but rather flow with whatever’s in fashion. However the tagging plugins written for Wordpress are not recognised by Technorati and the use of Technorati tags is a big traffic driver for me.

Fortunately, Technorati does recognise the internal categorisation system of Wordpress as an alternative to Technorati tags. So I’ve decided on a hybrid system. After much testing of alternative plugins, I’ve installed Jerome’s Keywords plugin to satisfy my taxonomy needs. And I set up broad categories in Wordpress using popular search keywords like ‘Google’ and ‘RSS’. The Wordpress categories will not be visible, but Technorati will still pick them up in my RSS feed. And since it is not my primary taxonomy system, it won’t be a priority to always keep it up to date. When a search keyword falls out of fashion, I can simply delete the whole category without much of a loss.

« Newer Posts

Powered by WordPress