I'm having a problem with my yearly archives results. It is pulling posts from all years - not the correct years. For example, if I click on 2006 it displays posts all the way through 2012. Also on this page I noticed it was pulling a sidebar that is only supposed to show on the home page and isn't showing a sidebar that is supposed to show on every page, so that is strange, too. Any help would be appreciated!
Here is the code for archives.php:
<?php
/**
* Template Name: Archives
* Description: A Page Template that displays the Archives page
* The template in gets the posts tagged as archives
*
*
* @package WordPress
* @subpackage WP Theme
* @since WP Theme 1.0
*/
get_header(); ?>
<div id="contentwrap">
<div class="inside">
<div class="post-top"></div>
<div class="post" id="post-<?php the_ID(); ?>">
<h2 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<div class="entry">
<?php the_post(); ?>
<h3 style="font-weight:normal">Archives by Subject</h3>
<ul>
<?php wp_list_categories('exclude=&title_li='); ?>
</ul>
<h3 style="font-weight:normal">Archives by Year</h3>
<ul>
<?php wp_get_archives('type=yearly'); ?>
</ul>
</div>
</div>
</div></div>
<div style="margin-top:80px">
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>
And here's the code for archive.php
<?php get_header() ?>
<div id="contentwrap">
<div class="inside">
<?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()) { ?>
<br /><h2 class="title">Archive for the '<?php single_cat_title(); ?>' Category</h2>
<?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
<br /><h2 class="title">Posts Tagged With '<?php single_tag_title(); ?>'</h2>
<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
<br /><h2 class="title">Archive for <?php the_time('F jS, Y'); ?></h2>
<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
<br /><h2 class="title">Archive for <?php the_time('F, Y'); ?></h2>
<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
<br /><h2 class="title">Archive for <?php the_time('Y'); ?></h2>
<?php /* If this is an author archive */ } elseif (is_author()) { ?>
<br /><h2 class="title">Author Archive</h2>
<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
<br /><h2 class="title">Blog Archives</h2>
<?php } ?>
<?php $posts = query_posts( array( 'showposts' => 10, 'paged' => get_query_var('paged') ) );?>
<?php while (have_posts()) : the_post(); ?>
<div class="meta">
<a href="<?php the_permalink() ?>" style="font-size:18px;;"><?php the_title(); ?></a>
</div>
<?php
foreach((get_the_category()) as $childcat) {
if (cat_is_ancestor_of(9, $childcat)) {
echo '<br /><a href="'.get_category_link($childcat->cat_ID).'">';
echo $childcat->cat_name . '</a>';
}}
?>
<?php $author = get_post_meta($post->ID, 'Author', true);
if($author) : ?>
| <?php the_time('F Y'); ?><h3 style="font-size:14px;margin-top:0px;margin-bottom:-20px;"><?php echo $author; ?></h3><br />
<?php endif; ?>
<div class="post-content" style="margin-bottom:5px"><?php if (function_exists('smart_excerpt')) smart_excerpt(get_the_excerpt(), 55); ?><br /><a href="<?php the_permalink() ?>">Read more</a></div>
<br /><br />
<?php endwhile; ?>
<div class="navigation">
<?php
include('includes/wp-pagenavi.php');
if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
?>
</div>
<?php endif; ?>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>