Support » Fixing WordPress » Cross-month archive navigation

  • I did a search, but I don’t really know what this would be called.

    Anyway, how do I set it so that the archives page lists months of posts, so the user can begin in, say, March 2008, but then continue with the pagination going backwards even into February 2008, January 2008, December 2007? Right now, I’m only able to navigate pages of posts within the month the user clicks on. My client is demanding navigation cross-month, cross-year. I don’t remember this being an issue ever before in previous versions of WordPress, so I’m not sure what I have set up incorrectly… any help is appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You could use the wp_get_archives() function to output a list of monthly archives. Otherwise, I think you’re looking at writing a custom page navigation function.

    To be honest, I’m kind of surprised. Wouldn’t this type of functionality be desirable/default?

    Does anyone know of a plug-in that can do this?

    I did something like this for a blog on the home page.
    This is not the best solution but could work.
    The problem is the number of pages on the site.
    I’m working on this issue but if somebody can help.

    This is the code that goes on index.php (on template directory) before the content id

    if (is_home()) {
    $temp_query = $wp_query;
    $actPage = $_GET["paged"];
    if ($actPage == "" || $actPage == "1") $actPage = 1;
    	$current_month = date('m');
    	$current_year = date('Y');
    	$toShow = $current_month - ($actPage - 1);
    	if (!$toShow) {
    		$toShow = 12;
    	$strQuery = "&year=$current_year&monthnum=$toShow&posts_per_page=-1";
    	$strQuery = "&year=$current_year&monthnum=$toShow";

    and after the endwhile:

    <?php $wp_query = $temp_query; ?>

    The problem is the number of pages.
    After some pages this could start to show pages not found.
    Thanks for help.

    Byron H.

    Hi Byron,

    Thanks for the advice – I tried it out. I inserted the first code bit before:
    <h1 id="post-<?php the_ID(); ?>">

    and pasted the second bit after the endwhile, as instructed.

    This is on my archive.php page, as it’s for the archive postings that I want this functionality.

    However, this results in an emptied sidebar, with the following error in it:
    Fatal error: Call to a member function on a non-object in /wp-includes/query.php on line 10

    Please note the sidebar code is not in archive.php at all, so I’m not sure what’s happening here. Any help is appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Cross-month archive navigation’ is closed to new replies.