WordPress.org

Forums

Archives by category not working (8 posts)

  1. desmondo
    Member
    Posted 6 years ago #

    Hi all,

    I've been searching for ages and can't solve this problem.

    Here is the News category of my site:
    http://www.thegoodagency.co.uk/the-news/

    If you click a monthly archive link on the lower right menu, like December, you get this page:
    http://www.thegoodagency.co.uk/2008/12/

    The problem here is, it is showing all the-news archives, which is correct, but it's showing all the months, not just December. The title is working fine, but it shows the content for all months.

    In the archive.php template, I have specified that I only want show archives from 'cat-1' (IE - the-news category), as this is the only category I ever want to show archives for. I am doing this using query_posts just before the loop. So:

    <?php query_posts('cat=1'); ?>

    The archive template works fine if I don't add this line of code. As in, it will show only posts for the month that is clicked. The problem is though if I don't have this line of code, it will then show posts for all categories; not just the-news.

    So, what I want to do is have a template that only shows archive posts for the current category and the current month. Is there a way I can create an archive template that is specific to a category, like "archive-1.php"? Any other suggestion would be a help though too.

    Thanks

  2. desmondo
    Member
    Posted 6 years ago #

    Hi all, can anyone help me with this? I'm desperate :)

  3. Hedley
    Member
    Posted 6 years ago #

    I'd like to know this myself.

  4. desmondo
    Member
    Posted 6 years ago #

    If I find the answer, I shall let you know. Still looking unfortunately!

  5. doodlz
    Member
    Posted 6 years ago #

    I've been trying to find an answer to the same question for ages as well. Hopefully we'll be enlightened soon!

  6. Bonusball
    Member
    Posted 5 years ago #

    I had the same problem, but this site helped me:

    http://blog.kapish.co.in/2009/06/16/date-archive-for-a-category/

  7. jason ormand
    Member
    Posted 5 years ago #

    Instead of using

    <?php query_posts('cat=1') ?>

    Use

    <?php if (have_posts()) : ?>
    <?php if (is_month()) {query_posts('year='.get_the_time('Y').'&monthnum='.get_the_time('m').'&cat=1&showposts='.get_option('posts_per_page')); ?>
    <?php } ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php endwhile; ?>
    <?php endif; ?>
  8. Herudea
    Member
    Posted 5 years ago #

    Helpful. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic