Search code examples
wordpressloopsarchive

In WordPress, which file is used when a user clicks on a Monthly archive link?


I currently have a list of archives based on a monthly basis. This is generated using:

<?php wp_get_archives('type=monthly&limit=12'); ?>

This generates a list of months, January 2012, February 2012 and so forth.

Question: What template page does the visitor get directed to when they click on a month?

How can I tweak my existing loop to just show that months posts. My current loop is:

<?php get_header(); ?>

<div id="main" role="main">

<?php
if (is_home()) {
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("cat=-6&paged=$paged");
}
?>

<div class="inner">

<h1><?php trim(wp_title("")); ?></h1>

<?php include ('sidebartwo.php'); ?>

<section class="main-wrap twocol news">

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

<article class="box-style">

<time><?php the_time('M d') ?><span><?php the_time('Y') ?></span></time>

<h2><a href="<?php the_permalink()?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>  </h2>

<?php the_content(''); ?>

</article>

<?php endwhile; ?>                              

<div class="next-prev-wrap">

<span class="next"><?php next_posts_link( 'Older posts', $post->max_num_pages ); ?></span>
<span class="prev"><?php previous_posts_link( 'Newer posts', $post->max_num_pages ); ?></span>

</div>

</section>      

<?php endif; ?>

</div> <!-- /inner -->

</div> <!-- /main -->

<?php get_footer(); ?>

Solution

  • Ok well it seems the problem code in my loop was where I excluded category 6, here:

    <?php
    if (is_home()) {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=-6&paged=$paged");
    }
    ?>
    

    I needed to exclude that category so googled how to do so and found this 'Super loop' by Perishable Press, here: http://perishablepress.com/press/2007/08/06/super-loop-exclude-specific-categories-and-display-any-number-of-posts/

    Copy pasted that loop and replaced my existing one and all is working now.