Post Meta Data Section
The post meta data is the "administrative" information you provide to viewers about each post. This information usually includes the author of the post, when it was written (or posted), and how the author categorized that particular post. This lesson will show you some different ways to change your Theme design to display these important pieces of information in the manner you desire.
In many cases, the post meta data is positioned immediately following the post itself, though some Themes are designed to place this information at the top of the post, other designs feature the post meta data in the top or bottom of the sidebar, and some designs even place the information in the footer. Essentially, post meta data can be styled in many different ways and with a variety of details.
The default WordPress Theme places the post meta data basic information and tags below the post in a box, before the comments. A condensed version of the code looks like this:
<small>This entry was posted on <?php the_time('l, F jS, Y') ?> at <?php the_time() ?> and is filed under <?php the_category(', ') ?>. You can follow any responses to this entry through the <?php comments_rss_link('RSS 2.0'); ?> feed.</small>
The output result looks like this:
There are three template tags used in the post meta data. One, the_time(), is used twice with different results. The other two tags get the information about the categories and the link to the RSS feed from the database.
The template tag for the_time() can be set up with a variety of parameters to tell the time and date of the post from information drawn from the database. In the first usage, the parameters l, F jS, Y pull the post's date into a format that gives the weekday, month, date, and year. In the second usage, there are no parameters, therefore it just returns the time when the post was saved. You will experiment with these below in Changing the Time and Date.
The template tag the_category() displays the categories that the post belongs to. This template tag can be modified to feature different text, graphics and symbols between the graphics, and may even use a plugin to display graphics in place of the words. There are many ways to style these. In this example, the categories are listed with a comma to separate them.
The last tag is the comments_rss_link() which uses the parameter RSS 2.0 to identify the type of feed being used. You can also customize the feed tag, changing the way it displays the link information about the feed and type, or even have it feature feed icons instead of text.
Changing the Text
Let's start to rearrange your post meta data with small steps. The first step is to change the text but not the tags. After all, this is your website and you want it to say things your way, right? This example makes the post meta data a little more conversational:
<small>I slaved away at the computer on <?php the_time('l, F jS, Y') ?> at the ridiculous time of <?php the_time() ?> when I could have been doing something much more productive. I slapped this thing into the <?php the_category(' and ') ?> categories, just to make you think I have some organizational skills. If you can really be bothered, you can keep track of what people have to say about my silly writings through the <?php comments_rss_link('RSS 2.0'); ?> feed, but I wouldn't bother. No one else who reads this babble has anything worthwhile to say.</small>
This would result in:
Okay, there is a small change. Did you catch it?
The usage of the_category() template tag, the parameter that sets the separator between the list of categories where the post belongs, was changed from a comma (,) to the word "and". It makes more sense in this situation.
Now, you can also cut the chatter and make your post meta data short and sweet:
POSTED: <?php the_time('m/j/y g:i A') ?><br /> FILED AS: <?php the_category(', ') ?><br /> COMMENTS FEED: <?php comments_rss_link('RSS 2.0'); ?>
Here is a very short list of your post meta data:
Changing the Time and Date
There are many ways to change the time and date within your post meta data to reflect a more appropriate use for your website or your cultural timekeeping methods. For example, in much of the world, the date is not month day, year but day month year. In the post meta data, you would change the template tag the_time() so the paramters would show "Monday, 21 February 2005":
<?php the_time('1, jS F Y') ?>
To add more interesting information to your post meta data there are several plugins available which generate the date the post was last modified. Two such plugins are Kaf Oseo's Post Updated and Nick Momrik's Last Modified. In the following example, using various ways of manipulating time with PHP tags, we'll add Nick Momrik's plugin to the mix, mdv_last_modified():
<div class="postmetadata">This post was written on what I think was a <?php the_time('l'); ?>, but I know it was the <?php the_time('jS'); ?> day in the month of <?php the_time('F'); ?> in the year of <?php the_time('Y'); ?>, though I messed around with this on the <?php mdv_last_modified('dS'); ?> day of <?php mdv_last_modified('F'); ?> in <?php mdv_last_modified('Y'); ?>, a not-so-busy <?php mdv_last_modified('l'); ?> when I had nothing better to do.</p></div>
Which would result in:
Adding Template Tags
So far, you've covered only three of the many template tags you can add to your post meta data. You can add the the_title() to get the title of the post. If you want the author's name, you can add the_author() and even the author's email with the_author_email(). Want a link to all the posts written by a specific author? That can be arranged with the the_author_posts_link().
What if you want to include more basic information like the title of the website using bloginfo(), or navigation help like the previous_post() and next_post()? We're using the next and previous post template tags to list posts within the same category, available to users of WordPress 18.104.22.168+. These are just a few examples of the many possible uses of template tags in your post meta data
In the most simplest of usages, the post meta data could be listed as:
POST TITLE: <?php the_title(); ?><br /> AUTHOR: <?php the_author(); ?><br /> POSTED: <?php the_time('jS F Y') ?><br /> FILED AS: <?php the_category(', ') ?><br /> COMMENT FEED: <?php comments_rss_link('RSS 2.0'); ?><br /> PREVIOUS: <?php previous_post('%', '', 'yes', 'yes'); ?><br /> NEXT: <?php next_post('%', '', 'yes', 'yes'); ?>
And would look like this:
If you want this in your sidebar, and you want a more conversational style, then in your template file, sidebar.php, find a good spot to put the following:
<div class="postmetadata"><p>You are reading the article, <?php the_title(); ?>, on our website, <?php bloginfo('name'); ?>. This article was written on <?php the_time('jS F Y') ?>, in Seattle, Washington, and you can find similar articles in the <?php the_category(' and ') ?> categories, or more articles by <?php the_author_posts_link() ?>, if you enjoyed this article. If you have any comments about this article, you can contact <?php the_author() ?> by <a href="mailto:<?php the_author_email(); ?>"> email</a>, or leave a comment below. You can also follow comments made on this article via our <?php comments_rss_link('RSS 2.0'); ?> feed.</p> <p>If you would like to continue reading more, <?php previous_post('the previous article on our site is called %', ' ', 'yes', 'yes'); ?> <?php next_post(' and the next article is called %', ' ', 'yes', 'yes'); ?>. Thank you for visiting our site.</p></div>
This example, if styled in a narrow column found on most sidebars, would look like this:
This is just the beginning. There are many ways you can style your post meta data; by putting it in a box, by making it part of the text, by having it in a list...it's up to your imagination how you want to style your post meta data, and what information you want to share with your public about your posts.