scriptygoddess

27 Jun, 2004

Previous Archive Date / Next Archive Date links

Posted by: Jennifer In: WordPress Plugins

This plugin will allow you to put next / previous links for date archive pages. For example, you're looking at the archive page for "January 7, 2004" – it will put a link to the previous day and next day page. If there are no posts on that day – it will look for the next available day that has posts. So in our example – if we had posts on January 6, January 7 (the page we're looking at) and there wasn't another post until January 10. Calling the two functions in this plugin, you could do this:

« January 6, 2004 | Home | January 10, 2004 »

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

Installation Instructions:
Step 1: Download and activate this plugin in the plugin control panel in wordpress
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.

Step 2:You can now use the two following functions:

previous_archive_date()
next_archive_date()

Each function will take two (optional) strings passed to it. The first string is text or html to display before the link. The second is the text or html to display after the link. Default for both of these is blank. So:

previous_archive_date($before=", $after=")
next_archive_date($before=", $after=")

To achieve the original example – place this code OUTSITE the start of the WP loop, with the following surrounding code (so the "home" link doesn't display unless we're looking at a date archive page) :

<?php if (isset($_GET['m']) || (isset($_GET['year']) && !($single))) { ?>
<p><?php previous_archive_date('&#171; ',' |'); ?> <a href="<?php bloginfo('url'); ?>">Home</a> <?php next_archive_date('| ',' &#187;') ?></p>
<?php } ?>

Change Log
New in ver 2.0:
Let's give that permalink support another try, shall we?! :)
get_year_link function thanks go to Charles G. of blindmuse.com
Localization support.
Streamlined code.
Support for up2date plugin

New in ver 1.0:
Now works with permalinks. Many many bugs fixed.

UPDATE 11/26/2012
I was contacted by a reader that they've recently taken this idea and updated it and made a plugin out of it. More info can be found here:
Adjacent Archive Links for WordPress
The plugin can be found here: Adjacent Archive Links Plugin

49 Responses to "Previous Archive Date / Next Archive Date links"

1 | Blogging Pro - Blog News, Tools and Hacks » WordPress Plugin: Previous and Next Archive Date links

June 28th, 2004 at 2:03 am

Avatar

[…] ks slvShowNewIndicator(1088388216); Filed under: WordPress Plugins|Google it! Add next / previous links on your date archive pages […]

2 | evolution: i'm ahead, i'm advanced

July 6th, 2004 at 7:05 pm

Avatar

[…] ther than taking readers to a different page. A simple image browser for the admin screen. Something to generate "previous" and […]

3 | One Woman, Five Cats and a Crowbar » More Navigation Than You Can Shake a Stick At!

August 26th, 2004 at 6:39 pm

Avatar

[…] dd previous | main | next navigation to single-post pages. Yippee! Then I activated the Next/Previous Date Archives Plug-In (which worke […]

4 | Rickie Beth

June 27th, 2004 at 7:47 pm

Avatar

Thank you for posting this! I already did this manually to my install, but the lack of previous/next links in the single post pages is one of WP's biggest flaws, in my opinion. It drives me nuts to not be able to read posts without going back to the main page, and hopefully this will help fix that. So thank you! :)

5 | Jennifer

June 27th, 2004 at 7:57 pm

Avatar

Rickie Beth – This plugin isn't for "single post" pages. It's for "date archive" pages. For next/previous links on single posts – see this post for details

6 | Becky

June 27th, 2004 at 8:12 pm

Avatar

Quick question for you Jen. Will this work for monthly archives as well (for instance, would it display "April 2004 | Home | June 2004" if you're on the 'May page')? Or does WP already have something for that (I only have posts for this month)?

7 | Jennifer

June 27th, 2004 at 8:17 pm

Avatar

Becky – yup. It will work with year, month and day archive pages. (One small note: I just edited the post to explain that the script currently only works with permalinks NOT turned on). I'm working on fixing that… I'll leave a comment and update the post when I do finish.

8 | Blogging Pro - Blog News, Tools and Hacks

June 27th, 2004 at 10:03 pm

Avatar

WordPress Plugin: Previous and Next Archive Date links
Add next / previous links on your date archive pages.you're looking at the archive page for "January 7, 2004" – it will put a link to the previous day and next day page. If there are no posts on that day – it will look for the next available day tha…

9 | Jennifer

June 29th, 2004 at 10:23 pm

Avatar

I forgot to post this yesterday – but the plugin has been updated to ver. 1.0 – now works with permalinks and many many bugs have been fixed. :)

10 | BB

July 4th, 2004 at 11:07 am

Avatar

I posted part of my problem here on the WP support forums. However, I thought it best to ask here for help, too, as peeps here seem to be more in-the-know concerning these issues.

Currently, I have archive dropdowns that display month-year combos. What I want are three things:

1. When a user clicks on one of those combos, s/he is sent to the first single post of that month-year.

2. A previous entry/next entry link. (I believe that this plugin can solve that issue.)

3. Some kind of integration into the latest entry. I have my blog set up to display only a single entry. I would like a previous entry link on that entry, somehow seamlessly integrated into the whole archiving previous/next scheme.

The navigation should flow easily for a user, like turning the pages in a book.

Any advice you can give me to get these three things is much-appreciated.

11 | Mark J

July 4th, 2004 at 1:48 pm

Avatar

BB,
1. This will need a custom plugin
2. This functionality already exists in WordPress.

Here is what I currently use for it:

<?php if ($single) { ?>
<div class="menu">
<?php previous_post('%','<img src="http://www.mysite.com/images/l_arrow_plain.gif" alt="l_arrow" align="middle" /> Previous Entry','no','no',1,"); ?> |

<a href="<?php bloginfo('url'); ?>">Main</a>
|
<?php next_post('%','Next Entry <img src="http://www.mysite.com/images/r_arrow_plain.gif" alt="r_arrow" align="middle" />','no','no',1,"); ?>

</div> <!– class="menu" –>
<?php } ?>

3. You can put that previous code where ever you like, really.

12 | 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…

13 | Ruby Sinreich

July 10th, 2004 at 1:40 am

Avatar

Thank you thank you! This is just what I needed and it works perfectly.

14 | Daxeel

July 13th, 2004 at 7:37 am

Avatar

My blog is not in english, is it possible to change this script so it use the /wp-includes/locale.php file to show the months and the weekdays in my language?
Thank you in advance.

15 | BB

July 25th, 2004 at 3:17 am

Avatar

Is there any way to have the two-digit year number after the three-letter month name at the bottom of the calendar (i.e., Jan '02 instead of just Jan)?

16 | quayso

July 27th, 2004 at 12:27 am

Avatar

Ooh, I most useful plug-in, thank you.

I have perhaps found one bug … I have monthly archives. For example, let's say I had posts in May and July, but not June. July will not have a prev link (where it should be May!), even though May has a next link.

http://quayso.com/notebook

17 | Sameer

July 30th, 2004 at 9:02 am

Avatar

Hi. Thanks for making this excellent plugin! :)

I'm using v1.0 and it works wonderfully well except for one thing. It refuses to show the previous|Home|next links on permalinks! :(

You could have a look here … http://www.opti-mystic.net/blog

18 | Sheana

August 15th, 2004 at 10:49 am

Avatar

I'm having a teensy problem with this. I've installed and activated the plugin, that went fine, but when I include

< ?php if (isset($_GET['m']) || (isset($_GET['year']) && !($single))) { ?>
<p>< ?php previous_archive_date('« ',' |'); ?> <a href="<?php bloginfo('url'); ?>">Home</a> < ?php next_archive_date('| ',' »') ?></p>
< ?php } ?>
template, nothing shows up. I may just be misunderstanding the whole "outside of the wp-loop" thing… can you explain a bit more, for the non-technically inclined? :)

19 | Jennifer

August 15th, 2004 at 1:20 pm

Avatar

Sheana – I updated the post with the link to an explanation of the Word Press Loop on the wiki. It would also help to see an example of what you're doing. Please email me. (scripty AT scriptygoddess DOT com)

20 | One Woman, Five Cats and a Crowbar

August 26th, 2004 at 2:39 pm

Avatar

More Navigation Than You Can Shake a Stick At!
Scriptygoddess rocks! After living with Breadcrumbs for a few days, I came to the conclusion that it just wasn't sufficent navigation, especially for readers who aren't familiar with the typical stucture of a blog. I wanted date archives as well as…

21 | girlwonder

September 16th, 2004 at 9:47 am

Avatar

here's my issue. when i activite this plugin as well as paginate – i got to my template to add it to my index – and all i see is code for the actual plugin. any idea what causes this?

22 | Jennifer

September 16th, 2004 at 10:25 am

Avatar

girlwonder – I have heard of this problem before – and while I don't know the specifics – I think it has to do with some kind of an encoding issue due to whatever file editor the person was using. Maybe try opening up the plugin file with a VERY basic text editor – like notepad – and resaving it and uploading the resaved version…

23 | girlwonder

September 16th, 2004 at 11:10 am

Avatar

thanks jennifer. i tried that and it worked – but then for whatever reason – i couldn't get the pagination to show up. i'll give it a try some time later today maybe. thanks for your help :)

24 | Mark J

September 16th, 2004 at 1:00 pm

Avatar

For future reference, when people say that they activate the plugin and all they see is the plugin code, it usually means that they downloaded and saved the phps file, instead of viewing it in a browser, copying the text to notepad, and saving it as a php file.

25 | Jack

September 26th, 2004 at 2:35 pm

Avatar

I saw that someone asked this before, but my site is also not in english, and I'd like to have the names for the months in my own language (dutch). How can I use the months from my locale.php file for this plugin?

26 | eRRaTiK

September 29th, 2004 at 8:57 am

Avatar

i'm having a similar problem to what girlwonder had.. when the plugin is activated and i navigate to the template page all the code is displayed (in fact if i navigate to any page it's the same). i tried the fix (opening in notepad, wordpad and dreamweaver) and resaving but no luck. Also checked for space after the last ?>. Any other suggestions?

27 | Mark J

September 29th, 2004 at 9:22 am

Avatar

eRRaTiK, click the link to the "phps" file, and then copy paste the code into notepad. Do NOT use your browser to save the phps file. The file is colorized HTML which will not work. You need to copy-paste the outputted text.

28 | eRRaTiK

September 29th, 2004 at 9:55 am

Avatar

oh nice! works. thanks Mark J!

29 | Fer

October 23rd, 2004 at 4:56 pm

Avatar

Thank you Jennifer for this wonderful plugin! I'm migrating from MT to WP (well I'm experimenting with WP to do the final step). Anyway, The plug in works great, but I'm using separate template files, so when you click on the link to the next month, you get the entries but on the "main" (index) template and it doesn't show the modifications I added to the other template. Is there any way to make the plugin respect the configuration for the permalink?

And as someone asked earlier, is there any way to show the dates in other language? Because my whole template is in spanish and it really doesn't look good to have those dates in english.

I hope you understood what I said, my english's really bad lately!

And once again, thanks for the plug in! I hope at some point you get the chance to create a plugin as this but for next and previous categories! I'm really missing that MT plug in!

30 | Jennifer

October 23rd, 2004 at 5:01 pm

Avatar

The permalink issue should have been fixed – so I'm not sure what's going on there. But as for the date translation, I only had a moment to look at it when it was asked about originally, and it seemed a little more complicated. Not that it couldn't be done – but just that it would take time. unfortunately, time I don't neccesarily have at the moment.. So that feature may be a while before it's included.

As for the next previous categories – I already have a plugin like that.

31 | Fer

October 23rd, 2004 at 5:40 pm

Avatar

Oh, it's shame about the translation thing…

Two things: I was checking your monthly pages and the links take you "www…?m=200406" and not to "www…archives/2004/06/" so that's why I asked you if there was any way to make it work with permalinks.

The other thing, I saw your other plug in, but it works for permalinks and it takes you to the next post in the same category, I was looking for a plug in to let me navigate through categories like "< birds | home | dogs >" if I were at "cats" category. I've searched everywhere and I haven't found what I needed.

Anyway, thank you very much for replying so fast!

32 | Fer

October 23rd, 2004 at 5:42 pm

Avatar

Oops, I shouldn't have use a symbol, what I meant at the categories was to see a navigation menu like "birds (home) dogs" if I was at "cats" category. Sorry about that!

33 | Jack

October 29th, 2004 at 5:51 pm

Avatar

It's been some time since I asked for a possible solution for foreign languages. I've been looking into it myself a second time, but I'm not so familiar with php, although it must be in the region of $fordisplay = getdate ("F, Y", timestamp) that something possibly could be done with an if-statement? Just changing values before it is actually displayed on the blog?

I know these things take time, and I know English is the leading language, but your plugin is the only one available that does this trick. Coming from MT half a year ago I still find it impossible to understand that blogsoftware like WP doesn't have this option. What else is a blog then kind of diary based on time/months/years?

Anyway,I stated this already several times in the supportforum of WP.

Whenever you find time to take a look at it… (perhaps around christmas)…

Untill then I'll use the plugin and accept that it's in english dates.

34 | Fer

October 30th, 2004 at 9:31 pm

Avatar

Maybe if we add some code to the language file we can translate the dates… I should try that and let you know about it, anyway, the language file searchs for the lines in the template and if you change the template the code may not work… I also tried translating to spanish the file "locate.php" but it didn't work…

And about the other plug in I ask… is there any chance to get this for WP?

Sorry, I really don't want to be a pain in the ass, is just that I really need it 😛

35 | Jack

October 31st, 2004 at 5:00 am

Avatar

I found a temporary solution that perhaps will end up as the final solution:
Just change the $forDisplay variable into "previous month" and "next month", in your own language of course. That works for me, because it's just as clear to me and the visitor what it means, and I think it's even superfluous to call the month by it's name…

36 | Fer

October 31st, 2004 at 2:08 pm

Avatar

That's a great solution Jack! I'll use it until I find a way to translate the month's names (I was an MT user, it's hard to leave those nice things behind :P)

37 | Jack

November 1st, 2004 at 12:17 pm

Avatar

Fer, just visited your site. Did you find a solution for those months? It looks as if it is working?

38 | Fer

November 1st, 2004 at 7:46 pm

Avatar

Nope, that's my blog running on MT, my WP tests blog is on http://www.dabomb.com.ar/woods2/ .

If I get the solution I'll email you! :)

39 | Jennifer

November 3rd, 2004 at 11:22 pm

Avatar

I've got the localization working as well as the permalinks… I'm working on cleaning a few other things up so that the script is more streamlined. Expect an updated release in a day or so… (I hope)

40 | Jennifer

November 4th, 2004 at 11:15 pm

Avatar

Plugin updated to 2.0. Added localization support, support for permalinks (for real this time!) 😉 did some MAJOR code streamlining, added support for up2date plugin.

41 | Mariann

December 4th, 2004 at 9:56 pm

Avatar

WordPress virgin here and PHP newbie… I feel really stupid for asking this question, but what template and/or file should I be editing to insert this bit of code after installing the plugin?

42 | Jennifer

December 4th, 2004 at 10:48 pm

Avatar

if you're referring to 1.3 templates – I should warn you I haven't tested the plugin with 1.3 yet! However, this would go in the main index.php file, wherever you want it to display the links.

43 | doug

January 15th, 2005 at 10:55 am

Avatar

is there any way to get this working on the homepage?

what i'm looking for is a way to simply link to the 'previous day' from the footer of a homepage that is always set to show the most recent day of posts.

as far as i know, wordpress template tags for previous posts work only with posts paged, and of course this plugin is design for archive pages.

any ideas? thx:>)

44 | Jack

January 25th, 2005 at 8:18 pm

Avatar

Same question here I guess. I'm using your plugin and it works great even with 1.5, but I would love to have it work on the homepage as well. A year ago I was using MT and there it was a standard thing to have the weblog started with the latest month that contains posts. And personally, for me that sounds as the logical way to go about.

Could this plugin be changed in some way to accomplish this?

45 | doug

February 24th, 2005 at 11:59 pm

Avatar

i still haven't figure out how to get a previous day (or previous week) link on the bottom of my 1.2 mingus blog homepage, which is set to show the most recent day of posts.

if anyone has any ideas, please holler:>)

46 | (~) wavestyle.ch/blog

May 9th, 2005 at 6:00 am

Avatar

Plugin update: Previous / Next Archive Date links
Previous / Next Archive Date links version 2.0.1-Hey

Yet another WordPress hack :-)

I use this very nice Previous / Next Archive Date links plugin written by Scriptygoddess.

But as I started to insert graphical Links into my archive pages, I …

47 | Hey

May 9th, 2005 at 6:41 am

Avatar

I added the ability to display an icon or a custom text instead of the day or month name. You can download my version here:
http://www.wavestyle.ch/blog/archiv/2005/05/09/plugin-update-previous-next-archive-date-links/

48 | Toto

May 16th, 2005 at 4:57 pm

Avatar

Hi friends how can i do this

<- previos | next ->

But on link title (mouse over) to show previous or next post name ???

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