• Hello all.

    I am using WordPress for a site, and I want to modify the theme so it is as I want. At this point, I want to use the monthly archives. What I miss is the possibility to link to the next and previous monthly archive. Well, I can link to them, but when these archives don’t excist, a 404 error will show up. What I have done until now:

    In archive.php at the top before everything:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    And at the bottom (before </div><!-- #content .hfeed -->), where I tested the displaying:

    <?php if ($m_prev) : ?>
    	[<a href="<?php echo get_month_link(get_the_time('Y'), $prev_m); ?>">View older archive.</a>]
    <?php endif; ?>
    
    <?php if ($m_next) : ?>
    	[<a href="<?php echo get_month_link(get_the_time('Y'), $next_m); ?>">View newer archive.</a>]
    <?php endif; ?>

    I understand that that the if-else stuff is not very beautiful, but it should work. What doesn’t work is the check at the top. It should check if a monthly archive has posts (I Googled how to do it). Does anyone have an idea?

    I found this plugin but couldn’t get it to work.

    I am using WordPress 3.2.1 with theme Autofocus.

    Philipp

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Link to previous and next month in archives’ is closed to new replies.