scriptygoddess

20 Jun, 2004

Today in weeks/months/years past

Posted by: Jennifer In: WordPress Plugins

The idea of this plugin was to create a version of this for WordPress. I am aware that there is another similar script – but I didn't want the actual posts pulled in – just the link to go see the posts for that day in the past. As well – I wanted to use it outside the WP Loop.

Current Version: v 2.0
Last updated: 11/17/04 10:37pm

So here's the plugin – installation and use are pretty simple:

1) Download and install this plugin (right-click save as.. with a .php extension) – upload to your wordpress plugins folder (wp-content/plugins/ ). Activate through the admin interface.
IMPORTANT NOTE ABOUT DOWNLOAD: Make sure you do NOT have any extra spaces after the last ?> in your copy of the file. Extra spaces will give you various "header already sent" type errors.

2) This plugin has the following three functions you can call:

<?php showYearsAgo(); ?>
<?php showWeeksAgo(); ?>
<?php showMonthsAgo(); ?>

All three functions take the following (optional) parameters:

-first parameter (number) is number of years/weeks/months the script should display in history.
default is 3 for years, and 1 for weeks and months.

-second parameter (string – enclose in single quotes) – text/html to show before each link.

-third parameter (string – enclose in single quotes) – text/html to show after each link.

-fourth parameter (boolean – true/false) should it show the date. If so it will display like this:
This day 1 week ago: 06/05/2004
Otherwise it will display just this:
This day 1 week ago

-fifth parameter (string – enclose in single quotes) is only used if the second parameter is true. This is what should be used as the seperator when displaying the date. Default is a slash: /

-sixth parameter (boolean true/false) should it display the titles from that date. Default is false.

-seventh parameter (string – enclose in single quotes) text/html to show before the group of titles. Default is '<ul>'

-eigth parameter (string – enclose in single quotes) text/html to show after the group of titles. Default is '</ul>'

-ninth parameter (string – enclose in single quotes) text/html to show before each title. Default is '<li>'

-tenth parameter (string – enclose in single quotes) text/html to show after each title. Default is '</li>'

So here's an example:

<?php showYearsAgo(2,",'<br />',true,'.'); ?>

If today's date was 3/10/2004 and there WERE posts on these days – it would show the following:

This day 1 year ago: 3.10.2003
This day 2 years ago: 3.10.2002

(except instead of the blank link – it will actually go to an archive page with all the posts from that day.

To display the link with the posts from that date (we'll use the showWeeksAgo() and showMonthsAgo() functions):

<ul>
<?php
showWeeksAgo('1', '<li>', '</li>', true, '/', true, '<ul>', '</ul>', '<li>', '</li>');
showMonthsAgo('3', '<li>', '</li>', true, '/', true, '<ul>', '</ul>', '<li>', '</li>');
?>
</ul>

I'm sure some people may want to change the way the date is displayed (ie. day first then month then year, or something else…) – to do that you can just modify one line. Look for the variable $forDisplay in each function. That is the one that will display the date.

Current Ver: v 2.0
new in v. 2.0
Added support for up2date plugin
Many updates thanks to JABecker:
Added ability to display post title(s) from archive page, cleaned up some code, added before after group and title code

new in v. 1.1
Bug fix error when not displaying date.

new in v 1.0
Fixed MAJOR bugs with showWeeksAgo and showMonthsAgo. – logic was breaking.

35 Responses to "Today in weeks/months/years past"

1 | Blogging Pro - Blog News, Tools and Hacks » WordPress Plugin: This Day In…

June 21st, 2004 at 2:55 am

Avatar

[…] ; slvShowNewIndicator(1087786523); Filed under: WordPress Plugins|Google it! This plugin lets WP bloggers add a link to posts from any number of […]

2 | Slobokan's Site O' Schtuff » Way To Go ScriptyGoddess!

June 21st, 2004 at 4:52 am

Avatar

[…] Category: BLOGGAGE @ 00:54:41 – 0 views

Hats off to ScriptyGoddess for yet another amazing plugin for WordPress.

OBITER D […]

3 | highlyoverrated.info - do you need more? » wordpress plugins

June 28th, 2004 at 6:36 pm

Avatar

[…] mage browser – voransicht der hochgeladenen bilder, zum direkt in neue einträge einfügen! today ago – links auf einträge am gleichen tag (vor 1 jahr, 1 m […]

4 | Persistent Illusion » A few changes

November 7th, 2004 at 6:19 pm

Avatar

[…] made a few changes to PI. The Wayback Machine is courtesy of Scriptygoddess' "Today in weeks/months/years past" WordPress plugin. I fix […]

5 | kristal

June 20th, 2004 at 9:49 pm

Avatar

this works beautifully – thank you!

6 | Blogging Pro - Blog News, Tools and Hacks

June 20th, 2004 at 10:55 pm

Avatar

WordPress Plugin: This Day In…
This plugin lets WP bloggers add a link to posts from any number of weeks, months, pr years ago. Kind of a this day in history…

7 | Shelagh

June 21st, 2004 at 3:32 am

Avatar

What does the plugin do if there is no post – does it not display anything at all or does it find the nearest date it can?

8 | Jennifer

June 21st, 2004 at 7:37 am

Avatar

It won't display that line at all. (Same as the original one that was done for MT)

9 | kristal

June 21st, 2004 at 4:27 pm

Avatar

actually – there is a problem. my RSS feed shows this error:

Warning: Cannot modify header information – headers already sent by (output started at /xxx/xxx/public_html/blu/wp-content/plugins/scripty_yearsago.php:140) in /xxx/xxx/public_html/blu/wp-rss2.php on line 10

10 | Jennifer

June 21st, 2004 at 4:54 pm

Avatar

errors like that tend to be copy/paste error. Line 140 is actually the ending ?> in the script. Make sure you don't have any spaces before/after it…

(If you want to be on the safe side – grab the zip version)

11 | kristal

June 21st, 2004 at 5:06 pm

Avatar

*feels stupid* thank you :)

12 | Jennifer

June 21st, 2004 at 9:23 pm

Avatar

Kristal – don't feel stupid. That's actually been happening alot – which is why I've started to offer downloads both as phps AND zip. :\

13 | Jennifer

June 22nd, 2004 at 8:34 pm

Avatar

I've discovered all sorts of bugs with this. (Nothing harmful – it's just not working) – Working on the fixes now…

14 | Jennifer

June 22nd, 2004 at 8:58 pm

Avatar

Plugin has been updated to v 1.0. All known bugs should be fixed.

15 | Bryan

June 30th, 2004 at 11:03 am

Avatar

How about a little exerpt from the post that was 1 year ago? That would be awesome for version 2.0

16 | Jennifer

June 30th, 2004 at 11:40 am

Avatar

Bryan – This plugin doesn't show links to a specific post – just the link to the archive page for that date (which could have several posts on that page). There is actually another plugin (look for it on the wiki – plugins section) that lists the links to the posts individually – and may also include an excerpt. I'll post a link to that plugin when I find it…(I won't be able to look for it until tonight)

17 | Bryan

June 30th, 2004 at 1:49 pm

Avatar

No, that's fine, It was just a suggestion. VERY nice site here Jennifer. I really love the BLOG AUTHOR image next to your name

18 | Jennifer

June 30th, 2004 at 8:01 pm

Avatar

Actually – since I found it :)
Here's the plugin I was thinking of.

But there probably is a way to modify this plugin to show the specific posts too…

19 | Christine

July 5th, 2004 at 12:07 am

Avatar

I just installed the plugin on my blog, and it works great with only one minor problem. The 2nd date's (of the two displayed) href tag isn't closed. The word below the last link is also a link to the text. Any thoughts on what parameter I might be missing that is causing that tag not to close?

20 | Christine

July 5th, 2004 at 12:43 am

Avatar

(I added a fake close a tag to make the last line close. Otherwise my RSS links and so forth weren't working right.)

21 | Jennifer

July 5th, 2004 at 1:03 pm

Avatar

Plugin updated to v. 1.1. All known bugs should be fixed.

22 | Mama Write

July 7th, 2004 at 8:01 pm

Avatar

Various WordPress Links
Rather than ping ScriptyGoddess multiple times and clog my sideblog with even more WordPress links, I decided to plop 'em all here. I'm going to give WordPress a try again on my course website, since there are various hacks that…

23 | paticoflange

July 8th, 2004 at 6:25 pm

Avatar

Hello, thanks for the great plugins! Question, I want to use this plugin for previous and next entry links, withOUT showing the dates. Instead something like "next entry" or just "next".

Would this be easy to implement? Ideas?

24 | Jennifer

July 8th, 2004 at 6:54 pm

Avatar

I wouldn't use this plugin for next previous links. Use one of these instead:
WP built in next previous
Next Archive / Previous Archive plugin

25 | Pia

August 7th, 2004 at 3:37 am

Avatar

Hey Jennifer! I think this plugin is very very interesting. I'm having some problems though, I've installed the plugin, activated it, put in the link, but the line doesn't show on my posts. Am I doing anything wrong? I used the showYearsAgo()

26 | AndrewSW: Blog

August 21st, 2004 at 10:45 pm

Avatar

New fiction series, attempt at encouraging creation of wisdom
So, as you may have noticed from my most recent post, I've started a new FICTION series called "Cursed". Please don't read too much into this – at lot of it is me recycling fragments of stuff I'd written a while ago, and looking at it to both remi…

27 | G'day Mate!

January 7th, 2005 at 7:55 pm

Avatar

On This Day
If you check over on the sidebar there is a new section which displays a link to the posts from a year ago. Today the link is pointing to 2004/01/08 which contained the 24 Aussie Commandments – a post I had forgotten about :-)
At the moment, it only s…

28 | Tin

February 3rd, 2005 at 1:09 am

Avatar

there seems to be another problem. it seems that the plugin only works if you use only one of the function calls. i tried using showyearsago AND showmonthsago at separate parts on the page. they work fine if i only use one call, but not more than one. is it possible to change this?

29 | Jennifer

February 3rd, 2005 at 9:23 am

Avatar

On a seperate blog, I'm using all three just fine. So you may have another conflict in your code.

(Please note that this plugin will need to be updated for 1.5)

30 | Tin

February 3rd, 2005 at 5:24 pm

Avatar

it appears that the function call of all three work fine. i know what the problem is… the calendar in WP is based on the server's time zone, regardless of what you set in WP options. this plugin uses the time and date of the calendar feature. i wonder if it's possible to get around this and for it to use the time that we set under options.

31 | Jennifer

February 3rd, 2005 at 6:05 pm

Avatar

Yes – you are correct – and I think that can be done. When I get the chance to update this plugin for WP 1.5, I will include that. However I doubt I will update the plugin for WP 1.3. (Heck – I'll be lucky to find the time to do the 1.5 update!!) :)

32 | Tin

February 3rd, 2005 at 8:11 pm

Avatar

thanks for the confirmation jennifer. i have two more questions.

the first… i always get confused by using the different parameters, so i avoided that by modifying the values in the plugin file itself. so in other words, i think i'm modifying the 'default' values. would that be okay?

and my second question… i'm using showmonthsago function right now. i've set the default value to show '3' past entries.

First scenarior. it shows an entry from one month ago, which is good.

Second scenario. it shows an entry from two months ago, but no entry from one month ago (because there were no entries one month ago), so that's good as well.

Third scenarior. however, when there is an entry three months ago but no entries one or two months ago, it doesnt show that entry from 3 months ago. is there a reason why this is happening? do entries from previous months require more recent entries to land on the same day?

thanks for all your help.

33 | Sylvain

March 20th, 2005 at 3:31 pm

Avatar

Hi Jennifer. Great plugin.
I am new to WordPress so what I am going to say may be wrong.

I tihnk I found a bug with WP 1.5
Your plugin displays the "PAGES" as entries… However when you click on the link WP says "Sorry, no posts matched your criteria."

Maybe your plugin does not handle "pages" ?

Anyway, great website and great plugin.
Thanks!
Sylvain.

35 | 葱白·后宫 » Blog Archive » 常用代码

July 15th, 2007 at 1:19 am

Avatar

[…] todayAgo – by Jennifer (Scriptygoddess) w/ updates by JABecker (persistentillusion.com) 去年今日……(另可顯示上月、上週的文章) […]

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements