Show posts by a category not working
-
Hi, i want to display my blog in a different page, not in index, and i want to show only the posts on a certain category.
I placed ‘cat=7’ but it is not working, it shows all the post as the category was not specify :SThis is my code:
<article> <?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query('cat=7'); $wp_query->query('showposts=5' . '&paged='.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <div class="post"> <h2><a href="<?php the_permalink(); ?>" title="Read more"><?php the_title(); ?></a></h2> <p><?php echo substr(get_the_excerpt(), 0,300); ?></p> </div> <?php endwhile; ?> <?php if ($paged > 1) { ?> <nav id="nav-posts"> <div><?php next_posts_link(' Previous'); ?></div> <div><?php previous_posts_link('Next'); ?></div> </nav> <?php } else { ?> <nav id="nav-posts"> <div><?php next_posts_link('Previous '); ?></div> </nav> <?php } ?> <?php wp_reset_postdata(); ?> </article>
Thanks a lot for your time.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Show posts by a category not working’ is closed to new replies.