Archive with monthly list for one category
-
I have a page (category-news.php) that displays all posts from category 1 (news).
In the left column i want to display a list with monthly archive, for this category.To display the month list, i use this code:
<?php wp_get_archives('type=monthly'); ?>
And for the posts, this loop:
<?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div class="right"> <h2><?php echo the_title(); ?> (<?php echo the_date(); ?>)</h2><span class="edit"><?php edit_post_link('EDIT'); ?></span> <h3>Posted by <?php echo the_author(); ?></h3> <div class="entry"><?php the_content(); ?></div> </div> <!-- right --> <?php endwhile; ?> <div class="navigation"> <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div> <div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div> </div> <?php else : ?> <h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <?php endif; ?>
The problems
1. The month list displays months when there is nothing written in this category, but in others.2. When clicking on a month, i get posts from all categories.
Well, I figured I had to put this before the loop in archive.php:
<?php query_posts('category_name=news'); ?>
With that code, I get the correct category – but I see posts from all moths, even if I click on a specific moth and the url is ending with ?m=200911
Anyone? Thanks.
- The topic ‘Archive with monthly list for one category’ is closed to new replies.