Support » Fixing WordPress » 2 Posts With Separate Archives

  • Resolved Swick


    I’m going to admit right now that I’m brand new to WordPress and trying to learn as much as I can, and I’ve been working for awhile trying to get this sorted out. There’s a site I’m building where the customer is looking for 2 separate post pages, so I created a different category for each. I created a template page for each of these such that they will only display posts from their respective categories (using query_posts(‘cat=x’)). The problem is that each of these sections need to have an archive which organizes by the year they were posted. I was able to place these archives by using

    <?php wp_get_archives('type=yearly'); ?>

    It seems to get the years, but if I click on the link it gives, they always default to archive.php and I can’t seem to find a way to pass the category I need to this page. What I need is to make the year in the specific post pages to either go to archive.php and have the correct category showing for that year, or have a way such that each go to their own respective PHP archiving pages. Any suggestions or help on how to do this would be gratefully appreciated. Just a heads up, I’m new to posting questions as well, so please be patient with me 🙂

Viewing 7 replies - 1 through 7 (of 7 total)

    On your archive page, one possible solution could be something like this:

    Edit: screwed up the code, this might work better:

    if ( in_category('fruit') ) {
    	//do fruit stuff
    } elseif ( in_category('vegetables') ) {
            //do veggie stuff
    } else {
    	// Continue with normal Loop
    	if ( have_posts() ) : while ( have_posts() ) : the_post();
    	// ...

    That doesn’t seem to work. Once the page starts using archives.php, then it pretty much forgets what category it’s using. The wp_get_archives code creates the links by year, but permalinks changes it all to So there doesn’t seem to be anything sending the category along to the next page.



    First off, if you are new to WordPress you’re in for a rough time. You’ll have to custom code a lot of what you’re looking to do unless you use a plugin. Here’s another post with some good info:

    Special reference to and the two plugins mentioned:

    Hope this helps…

    Thanks for the response. I’ll just have to try and sort it out. I’ve tried looking for a plugin that might do the trick, but there doesn’t seem to be a lot of options to do what I need. Is there anything you could suggest?



    I’m confused… I thought the plugin I suggested:

    was exactly what you were looking for??? It’s description is (note the bold):

    The WordPress Category Archive Widget Plugin displays a monthly or yearly archive of posts for one specific category. It is very similar to the WordPress Archive except that it just displays one specific category’s posts, not all categories. It can be configured to either show a listing or a pulldown by month or year with or without post counts.

    Oops, sorry about that. I think I’ve been staring at my monitor too long to have overlooked the link. Thanks again.

    OK, I didn’t quite get the problem the first time around…

    If those plugins don’t work, I suppose you could try passing a session variable between your pages.

    Maybe this is an overly complex way of doing it, but when you’re on the category x page, create a session variable to pass the category on to the archives page. Do the same thing for category y.

    Then when you’re on the archives page, you could construct a custom query that would grab the category from that variable, limiting the posts that are displayed to the category page you came from.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘2 Posts With Separate Archives’ is closed to new replies.