Wordpress and the iPhone.

This is just a quick test to check if the Wordpress application for the iPhone actually works. So far two drafts are gone. But I’m even going to try add a photo of a smashed mobile phone.

Smashed mobile phone

Wordpress plugin: wp-days-ago.

My very first attempt on a Wordpress plugin is actually just a copy/past job from my own CMS. I wanted to get functionality I could not find in any other plugins: I simply wanted to display the number of days since a post or page was published.

The plugin will only display years and days and will not take into account that 24 hours are one day. If you publish a page or a post at 23:59, it will be marked with “yesterday” at 00:00 even if it’s only a minute since you published. In some cases, the plugin will display a human readable text instead of the days count. Today is “today” and not “0 days ago”. Yesterday is, well, “yesterday”, while anything published seven days ago is posted “a week ago”. If an entry is more than a year old, the plugin will display the post date as “X year, Y days”.

If you want to use it yourself, simply follow these instructions:

  1. Download here (v1.0).
  2. Unzip the contents of the downloaded file to the /wp-content/plugins/ directory of your Wordpress installation.
  3. Log in to your Wordpress dashboard and activate the wp_days_ago plugin that should now be visible in the list.
  4. You can now insert <? wp_days_ago(); ?> anywhere in The Loop in your Wordpress theme.

The wp_days_ago plugin takes one parameter; the timezone offset between your Wordpress time zone settings and the server your Wordpress installation is running on. In my case I write everything in Central European Time, but the server is located in Sydney, Australia. That’s a -8 hour time zone offset from the server to my local time, and to get things right, I have to use -8 as the time zone offset parameter, like this: <? wp_days_ago(-8); ?>.

This plugin is also available through the Wordpress plugin directory.

About

Vegard SkjefstadYou're visiting the blog and personal web site of Vegard Skjefstad.

Entry Calendar

March 2010
M T W T F S S
« Feb    
1234567
891011121314
15161718192021
22232425262728
293031  

From Twitter

Vil du at jeg skal være slaven din? Nå har du muligheten: http://bit.ly/cSB4X1 (gjelder dessverre bare hverdager, 8-16) 16 hrs ago (follow me)

New Comments

vegard on "Three Weeks."
Kristoffer on "Three Weeks."
vegard on "Three Weeks."
Miguel on "Three Weeks."
vegard on "Hairy HDR."