Show posts by category – category ID not working

I have this code which works well except that it doesn’t get posts by the category ID. From the examples I’ve seen I would expect this to work – am I missing something?

<?php
$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
$args = array(
‘category’ => 172,
‘post_type’ => ‘post’,
‘posts_per_page’ => 10,
‘paged’ => $paged
);
$wp_query = new WP_Query($args);

while ( have_posts() ) : the_post();
?>
<h3 class=”publication-title”><a href=”<?php the_permalink(); ?>” title=”<?php the_title();?>”><?php the_title() ?></a></h3>
<p><strong><small><?php the_date(); ?></small></strong></p>
<p><?php the_excerpt(); ?></p>
<hr>
<?php endwhile; ?>

<!– then the pagination links –>
<?php next_posts_link( ‘&larr; Older posts’, $wp_query ->max_num_pages); ?>
<?php previous_posts_link( ‘Newer posts &rarr;’ ); ?>

Read more here:: Show posts by category – category ID not working

Leave a Reply

Your email address will not be published. Required fields are marked *