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.
Weekday plugin version 1.5
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.
In your template where you want to display the date for a post, replace:
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:
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.