Change query from cat id to slug or name?

Lets start by removing the query_posts() from your code since you already have it’s better brother new WP_Query.

Then what you will need is to use the category_name param on your WP_Query.

You should always search on the WP_Query page before you ask here, you can find more referencers there.


Here is how @speedypancake resolved the issue:

<?php 
$the_query = new WP_Query(
    array( 
        'posts_per_page' => '10', 
        'category_name' => 'books'
    )
);
while( $the_query->have_posts() ): $the_query->the_post();
    // Do what you want
endwhile;