Forums

Category and archive page (6 posts)

  1. jeffreyvr
    Member
    Posted 1 year ago #

    I have a slight problem.

    I'm having a website running on wordpress. This site contains a couple of categories such as news, questions, foods&drinks etc and that all goes well... but here's my problem.

    I wan't to have separate archives per category. But when I click on a month in my archive lists it automaticly uses the category page instead of the archive page.

    This is how i would like to have it:

    Category Page

    All posts in category news

    Post 1
    Post 2
    Post 3 etc

    --

    Archive page

    Posts in news - February (month)

    Post 1
    Post 2
    Post 3

    --

    Hope you guys understand what I mean, and have an answer for me.

  2. keesiemeijer
    moderator
    Posted 1 year ago #

    I'm not sure what you want. List only post with category "news" on date based archive pages?

  3. jeffreyvr
    Member
    Posted 1 year ago #

    That's correct.

    The problem is that I have different titles. On a category page I simply wan't to display the line 'all posts in category news' and on the archive page I wan't 'Posts in news - january 2011'.

    The problem is when I specify wich category should be archived it automaticly uses the category.php instead of the archive.php so that the title of the page is wrong.

    http://blog.nl/?m=201010 (displays archive page)
    http://blog.nl/?m=201010&cat=1 (displays category page)

  4. keesiemeijer
    moderator
    Posted 1 year ago #

    try and add a query before the loop in your archive.php:

    <?php
    global $query_string;
    query_posts( $query_string . "&cat=7" ); // if 7 is the ID of the "news" category
    ?>
    <?php while (have_posts()) : the_post(); ?><!-- start of loop -->
  5. jeffreyvr
    Member
    Posted 1 year ago #

    Thanks for your help, but that's not the solution for my problem (I'm grateful for your reply though). Maybe you could take a look at my previous post wich I just edited. Maybe it will make my problem a little more clear.

  6. keesiemeijer
    moderator
    Posted 1 year ago #

    How do you produce these links? with a wordrpress function?

    you can also try conditional tags is_category('7') or in_category('7') in the loop to show only "news" category.
    example of loop:

    <?php while (have_posts()) : the_post(); ?>
    <?php if(is_category('7')) : ?>
    <?php the_content() ?>
    <?php endif; ?>
    <?php endwhile; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic