I'm trying to make my own theme and I've created an archive template that works fairly well. The template shows all posts, but the problem is that all posts will show if I go to /2018/11/ (posts were created in different months) even though I've added monthnum
and year
in my query_posts
.
<?php
/**
* Template Name: Blog Posts
*/
?>
<?php query_posts('post_type=post&post_status=publish&posts_per_page=10&monthnum='. get_query_var('month') .'&year='. get_query_var('year')); ?>
<?php if( have_posts() ): ?>
<?php while( have_posts() ): the_post(); ?>
<div id="post-<?php get_the_ID(); ?>" <?php post_class(); ?>>
<div class="row featurette">
<div class="col-md-7">
<h2 class="featurette-heading"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p class="lead"><?php echo get_the_excerpt(); ?></p>
</div>
<div class="col-md-5">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( array(500,500, 'class' => " img-responsive center-block") ); ?></a>
</div>
</div>
<div class="featurette-divider"></div>
</div><!-- /#post-<?php get_the_ID(); ?> -->
<?php endwhile; ?>
<div class="navigation">
<span class="newer"><?php previous_posts_link(__('« Newer','example')) ?></span> <span class="older"><?php next_posts_link(__('Older »','example')) ?></span>
</div><!-- /.navigation -->
<?php else: ?>
<div id="post-404" class="noposts">
<p><?php _e('None found.','example'); ?></p>
</div><!-- /#post-404 -->
<?php endif; wp_reset_query(); ?>