Forums

Link to previous and next month in archives (3 posts)

  1. kirschplunder
    Member
    Posted 10 months ago #

    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

  2. kirschplunder
    Member
    Posted 10 months ago #

    The code that I put on top is:

    http://pastebin.com/5MiGBJrW

  3. ratsoid
    Member
    Posted 4 months ago #

    Hey kirschplunder, did you found a solution for this? I'm very interested in this as well

Reply

You must log in to post.

About this Topic

Tags