When I type “localhost/?cat=3” for example, to show all posts of category whose ID is 3, instead of doing it, it shows all posts of all categories (which is the job of my index.php), so I guess that a redirection to homepage is happening. I really don’t know what to do. Can you help me? Here is the code of index.php to retrieve posts:
<?php
$tmp = $wp_query;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$wp_query = new WP_Query('cat=-4&posts_per_page=5&paged=' . $paged);
if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
<div id="wrapper2">
<div id="topicos" >
<p id="titulo"><?php the_title(); ?></p>
<p id="data_public">Publicado em <b><?php the_time('j') ?> de <?php the_time('F, Y') ?> </b> por <?php the_author() ?></p>
<?php if(has_post_thumbnail()){
?> <div id="thumbnail">
<?php the_post_thumbnail(); ?>
</div>
<?php
}
?>
<div id="prv_texto"><?php the_excerpt(); ?></div>
<p id="cont_lendo"><a href="<?php the_permalink(); ?>">Continuar lendo...</a></p>
</div>
<?php endwhile; ?>
<?php endif; ?>
Have you tried making an archive.php file in your theme, and running a bare bone WordPress loop without a custom query before it?