photo by j.reed
Further thoughts on Dates within your blog (original post)
I’m no developer, but fortunately I can read php well enough to munge together what I need most of the time if I have enough examples of what I want.
And, in order to add the dates back here the other day, I had to go and figure out how to do it first which got me to thinking about different ways to incorporate a date within your blog…
How Do You Display the Post Date in WordPress?
Here’s the code:
<?php the_time(‘F j, Y’); ?>
You could mix up the variables of course, (this info was all dug up in the WordPress codex) depending on how you want it to appear:
l, F j, Y – Thursday, January 31, 2008
F j, Y – January 28, 2008
m/j/y g:i A – 01/31/08 4:38 PM
1, j F Y – Thursday, 31 January 2008
How Do You Display the Last Modified Date?
While I’ve never used it, apparently WordPress has a built in merge code for displaying the date and time your post was last modified but only works within the WordPress Loop (the post generation code). So:
Published on: <?php the_date(‘F j, Y’); ?> | Last Updated on: <?php the_modified_date(); ?>
Would look like:
Published on: January 14, 2008 | Last Updated on: January 28, 2008
Adding to Your Blogs Byline:
In the end I decided to add the dates back where I had removed them from in the first place, in the post meta data.
In wordpress, I simply edited my template (Presentation >> Theme Editor), opened up the Main Index Template file and added this:
| <?php the_time(‘F j, Y’); ?>
Mixing it Up Within the Text:
While a little more work, you could also intermingle your posts date information right within your content:
CES was incredible this year, it started on the <?php the_time(‘jS’); ?> of <?php the_time(‘F’); ?>. What a great start to <?php the_time(‘Y’); ?>!
Which would look something like:
CES was incredible this year, it started on the 14th of January. What a great start to 2008!
Adding the Date To Your Ending Byline:
Byline basically just refers to your posts identifying information and depending on your template may appear (as is the case with this blog) below the post title, or at the end of the post content.
Same code, different location!
| <?php the_date(‘F j, Y’); ?>
And while we’re talking about it… stick this code into the copyright (*sidenote – I just tried to write that as ‘copywright’ and it took me a minute to figure out why it just didn’t look right!) that probably appears in the bottom of your template (in the footer!)
Generally, if you have a copyright built into your blog template, it’s probably hardcoded. Now, I prefer to do everything online under a creative commons license, so I don’t have any copyright info on this blog, but if YOU do, save yourself the trouble of having to worry about updating dates every new year and stick to the following code:
Copyright & copy; <?php the_time(‘Y’) ?> <?php bloginfo(‘name’); ?>
Which would look like:
Copyright © 2008 Michael Valiant
I think that pretty much covers it! Can you think of any other GOOD uses for dates within wordpress?
** update: arg! I hate that wordpress tries to ‘Help’ with code sometimes… Just leave what I put in damn it! I’ve had to edit this post 20 times because wordpress seems to randomly change some of my html! I think I’ve got it now…