Support » Fixing WordPress » I want to show the monthly archive of that particular category only.

  • <?php if (have_posts()) : ?>
    <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
    <?php /* If this is a category archive */ if (is_category()) { ?>
    <h2> ‘<?php single_cat_title(); ?>’ Category</h2>

    <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
    <h2>Posts Tagged ‘<?php single_tag_title(); ?>’</h2>

    <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
    <h2>Archive for <?php the_time(‘F jS, Y’); ?></h2>

    <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
    <h2 class=”pagetitle”>Archive for <?php the_time(‘Y’); ?></h2>

    <?php /* If this is an author archive */ } elseif (is_author()) { ?>
    <h2 class=”pagetitle”>Author Archive</h2>

    <?php /* If this is a paged archive */ } elseif (isset($_GET[‘paged’]) && !empty($_GET[‘paged’])) { ?>
    <h2 class=”pagetitle”>Blog Archives</h2>

    <?php query_posts(‘cat=8&paged=’.get_query_var(‘paged’));


    <?php while (have_posts()) : the_post(); ?>

    <div <?php post_class() ?>>

    <h2 id=”post-<?php the_ID(); ?>”>“><?php the_title(); ?></h2>

    <?php include (TEMPLATEPATH . ‘/inc/meta.php’ ); ?>

    <div class=”entry”>
    <?php the_excerpt(); ?>


    <?php endwhile; ?>

    <?php include (TEMPLATEPATH . ‘/inc/nav.php’ ); ?>

    <?php else : ?>

    <h2>Nothing found</h2>

    <?php endif; ?>

    This code shows all the post in the particular category which is News. But the problem is that when i click the monthly archives for the month of september, it shows everything even the post from august. and also in august archives, it shows all the post including the september. I think the problem in my loop. Please help me with this

Viewing 1 replies (of 1 total)
  • Moderator keesiemeijer


    This is because you query the loop and telling it to show posts from category 8. Do you want to only show posts from category 8 on all your category pages?

Viewing 1 replies (of 1 total)
  • The topic ‘I want to show the monthly archive of that particular category only.’ is closed to new replies.