Adding tags to posts

If you have a pre-2.3 WordPress blog and didn’t use tags, you may want to go back and tag the old posts. If you don’t want to do that, you may want to adjust your theme so that you don’t have an empty field when your theme calls for the tags and there are none associated with the post. The Codex recommends this snippet if you want to check for tags before you render them:
if (the_tags(', ', ', ', )) the_tags();
This part of the Codex was added after I had already decided on the following code to return a true if there are tags associated with the post:
if (get_the_tags()) the tags();
Not as efficient but it works. If you don’t care about having empty fields in your theme, don’t worry about this. I think it’s a cleaner presentation with this check.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s