I'm using the following query to fetch posts in a category (10). I would like to change this code to use the category slug or name instead of the id number as this often changes when I move sites about.??
<?php $custom_query = new WP_Query(array ('cat' => 10, 'showposts' => 1)); query_posts($custom_query); while($custom_query->have_posts()) : $custom_query->the_post();?>
I've tried changing ('cat' => 'books'... ('cat_name => 'books'... & also ('cat_slug => "books"... but nothing seems to work.
Following the first suggestion I've now got this working:
<?php $query = new WP_Query('category_name=books'); while($query->have_posts()) : $query->the_post();?>
But now need help combining the "posts_per_page" bit of the query??