I create category.php for display categories archive in a costumed template.
In a category page link like this: http://www.example.com/category/cat1/
By these codes it’s OK and shows last items of cat1
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
// Some template code
<?php endwhile; ?>
<?php endif; ?>
But when I try to customize query by WP_Query or query_posts instead of contents of cat1 it shows contents of all categories of site
<?php query_posts( 'posts_per_page=30' ); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
// Some template code
<?php endwhile; ?>
<?php endif; ?>
What is reason and solution?
You must define cat in your query.
it’s your answer: