Weekday plugin

When I first moved over to WordPress as a blogging platform in June 2004, I wasn’t able to find a way to get the date for my posts to display Today or Yesterday. I had been able to when I used MovableType. What I’m talking about is:

  • If the post was posted today, it will put Today.
  • If the post was posted yesterday, it will put Yesterday.
  • Otherwise it will put the actual weekday (i.e. Monday).

So … I wrote one of my first WordPress plugins. It’s the only one I wrote that I still use.

Download:
Weekday plugin version 1.5

Installation:
Installation is simple. Just unzip the downloaded file and upload it to the /wp-content/plugins/ directory in your WordPress install. Then go to the Plugins page in your WordPress Admin and activate the plugin.

Usage:
In your template where you want to display the date for a post, replace:
[php][/php]
with
[php][/php]

This will display the date for every post, even if there are multiple posts for the same day. This tag must be used within The Loop

You can customize the format of the date, HTML to put before and after the date (i.e. surround the date in a container), and a separator between the Weekday and the rest of the date. You can also specify if you want to display the date or add it to a string and display it elsewhere:
[php]weekday_date($date_format=””, $container_start=””, $container_end=””, $separator=””, $echo = true)[/php]

$date_format can be anything you want. See the date() function for possibilities.

On this site, I am using the following to display the date:
[php]‘); ?>[/php]

Questions?
If you have any questions about the plugin or any problems, please let me know.

I hope someone out there can find this useful. If you do, please let me know. Leave a comment with a link to your site.

Comments

  1. Hello! I recently stumbled upon your site while looking for a WordPress version of the Yesterday/Today time stamp. Your version was by far the easiest to implement. I’m only having one minor issue, and due only to my own failings for PHP. I’ve tried to break down your coding to have it read only Yesterday or Today for recent posts, but the date for anything older. ie; Today, Yesterday, Oct 20 2007. Is there a way to do that? And have I been incredibly dense to have not seen it?

Comments are closed.