Support » Plugins » category to category navigation

  • I’ve been looking for something like this for a while.

    I need to be able to place navigation links on my category pages, but the links would go to the next category (either by increasing the ID# by 1, or by choosing which categories are part of the array to pull from within an admin).

    I’m using my categories like a calendar for movie release dates, and each movie is its own post. Each post is assigned a category for its release date and I would like to be able to put a “Next Week” link on the category template that would automatically go to the next release date.

    It would be far too time consuming and inconvenient to create a separate category template for each release date.

    Does anyone know if such a plugin exists? or is anyone willing to create one for me? If so, I am willing to pay.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Please, don’t double post. We are quite fast with the delete button.

    my apologies, i’ll be sure to not do it again, and thanks for the gentle warning.

    I hate assuming if the current post is in category 3, then the next thing you want to see is in category 4. That means you need to be almost anal about maintaining your categories.

    So with that said, this might work. It has to be in The Loop.

    $cat = get_the_category(); $cat = $cat[0];
    $next_cat = $cat->cat_ID + 1;
    wp_list_categories('include=' . $next_cat);

    This assigns and increments the category id of the current post to $next_cat, then uses that to provide a link to that next category using the include parameter of wp_list_categories().

    Guess you could us the same thing to decrement the category to go backwards.

    yeah, this wouldn’t be from a post’s category link to the next category, but from the category archive page, to the next category archives page.

    i guess the best example would be to go to’s Now Playing page, and let’s say that page is the current category. the code you provided would be like the “Next Week” or “Next Month” button at the bottom of the page. I’ve set it up so that the categories increment exactly as needed with only a few exceptions.

    Would that code provide the ability to skip categories? like say i am on category 140, but i want to skip to 142 because 141 isn’t part of the sequence i want, is that still possible?

    EDIT: re-reading your post, you mention it has to be in The Loop. I don’t think what I want needs to be in the Loop, otherwise it would be generated on every post on the category archive page.

    Well you can try this on a category archive page (like archive.php in the default theme) outside the loop.

    $cat = intval( get_query_var('cat') );
    $querystr ="
      SELECT cat_ID
      FROM $wpdb->categories
      WHERE category_count != 0
      AND cat_ID > $cat
      LIMIT 1";
    $next_cat = $wpdb->get_col($querystr);
    if ( !empty($next_cat) )
    wp_list_categories('hierarchical=0&title_li=&include=' . $next_cat [0]);
    echo 'No more categories';

    that works, thank you very much, but i have a few questions about it.

    1. how would i exclude a category or multiple categories? a separate ‘if’ statement where if next_cat=”cat-ID-I-dont-want” +2 or something?
    2. what would i change to make it go backwards and would having a backward and forward on the same page break anything?
    3. how would i stylize the link? if i wanted to display an image instead of text. the image for forward would always be the same image (image saying NEXT WEEK), and the image for backward would always be the same (image saying PREVIOUS WEEK).

    1. You’ll need to expand/improve the WHERE clause to match your requirements (see )
    2. You’d likely need another query string which uses the less than operator on the cat_ID and the ORDER BY clause.
    3. Probably need to use a different template tag like get_category_link and structure the ‘a tag’ accordingly.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘category to category navigation’ is closed to new replies.