Jan 07
Mon
08

Weekday plugin

Posted at 7:54 pm in Development, Word Press
Trackback

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 the_date(); ?>

with

<?php weekday_date(); ?>

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:

weekday_date($date_format="", $container_start="", $container_end="", $separator="", $echo = true)

$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 weekday_date('d M Y','','', '<br />'); ?>

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

Kat

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?

Leave a Reply

:rain: :blush2: :zzz2: :blush: :shock: :huh: :party: :doh: :) :winky: :frown: :clap: :wave: :think: :biglol: :whew: :pbbt: :sick: :p :storm: :angel: :drinkbeer: :hand: :question: :cowboy: :kiss: :banghead: :grin: :dance: :edit: :wha: :pissed: :S :2cents: :mad: :| B) :rolleyes2: >:) :giggle: :zzz1: :loser: :nailbite: :roflol: :cool: :D :arrow: :soapbox: :rofl: :bateyes: :razz1: :cry: :ligntning: :wink: :hey: :o :shh: :footmouth: :( :censored: :cry2: :rolleyes: :hugs: :drool: :crossfingers: :exclamation: :biggrin: :nahnah: :pin: :love: :beanie: :razz2: :crazy: :idea: :lol: :fullbeer: :thud:

I'm a Redneck Woman
Archives

Search
 
I'm a High Tech Broad
Stats
438 Posts & 75 Comments
Since 07 January 2007

50 queries in 0.368 seconds.
Feeds
Advertising
Meta
BlogRoll
Other Stuff
50% High Tech  50% Redneck
100% Woman
Valid CSS  Valid XHTML
This site looks best in Firefox  This site looks best at 1024x768 or higher
Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
Where You Can Find Me
twitter   flickr   brightkite   infield parking   facebook
myspace   friendfeed   jaiku   pownce   dopplr
Twitter
  • Crap. I don't know if that includes today's calls. CRAP!!! 9 hrs ago
  • Shit. How did I go over my cell minutes this month? Only 17, but still. Dammit. I guess I shouldn't have called home so much today. 9 hrs ago
  • Oh ... I am such a piggy. I ate 2 pieces of pie. 9 hrs ago
  • More updates...

Powered by Twitter Tools.

TwitterCounter for @hightechredneck
Affiliates
HostGator.com Affilliate

Get Smart. Get FireFox!

Get Thunderbird!
Other Cool Sites
kirtsy!
Tag Cloud
Recent TwitPic Uploads