Today in weeks/months/years past

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. kristal Says:

    this works beautifully - thank you!

  2. Blogging Pro - Blog News, Tools and Hacks Says:
    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…

  3. Blogging Pro - Blog News, Tools and Hacks » WordPress Plugin: This Day In… Says:
    [...] ; slvShowNewIndicator(1087786523); Filed under: WordPress Plugins|Google it! This plugin lets WP bloggers add a link to posts from any number of [...]

  4. Shelagh Says:

    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?

  5. Slobokan's Site O' Schtuff » Way To Go ScriptyGoddess! Says:
    [...] Category: BLOGGAGE @ 00:54:41 - 0 views

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

    OBITER D [...]

  6. Jennifer Says:

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

  7. kristal Says:

    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

  8. Jennifer Says:

    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)

  9. kristal Says:

    *feels stupid* thank you :)

  10. Jennifer Says:

    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. :\

  11. Jennifer Says:

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

  12. Jennifer Says:

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

  13. highlyoverrated.info - do you need more? » wordpress plugins Says:
    [...] 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 [...]

  14. Bryan Says:

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

  15. Jennifer Says:

    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)

  16. Bryan Says:

    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

  17. Jennifer Says:

    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…

  18. Christine Says:

    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?

  19. Christine Says:

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

  20. Jennifer Says:

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

  21. Mama Write Says:
    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…

  22. paticoflange Says:

    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?

  23. Jennifer Says:

    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

  24. Pia Says:

    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()

  25. AndrewSW: Blog Says:
    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…

  26. Persistent Illusion » A few changes Says:
    [...] made a few changes to PI. The Wayback Machine is courtesy of Scriptygoddess’ “Today in weeks/months/years past” Wordpress plugin. I fix [...]

  27. G'day Mate! Says:
    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 Says:

    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 Says:

    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 Says:

    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 Says:

    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 Says:

    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 Says:

    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.

  34. WP Plugins DB » Plugin Details » todayAgo Says:

    [...] Visit [...]

  35. 葱白·后宫 » Blog Archive » 常用代码 Says:

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