A WordPress filter that when added to your functions.php will alter the number of posts returned for a specific post type on an archive page

You can set the number of results per page in the WordPress dashboard in Reading settings and by default this is 10 per page but changing this effects all post types, including your blog.

This function is useful if for example I have a custom post type called ‘portfolio’ and wanted to return all posts within that post type because I had an infinite scroll / masonry / isotope setup on that specific archive page, a bit like Pinterest. What it does is modify the $query object before it is run.

The filter firstly checks if we are in the main query loop, or in the dashboard as we don’t want to modify those at all. Then we check if we are in our CPT archive page and if the query post_type is set to our CPT name, ‘portfolio’. If we are then we modify the query variable ‘posts_per_page’ to ‘-1’, which means retrieve all posts on this CPT archive.

function wpse63424_filter_pre_get_posts( $query ) {
 if ( is_admin() || ! is_main_query() ) {
 return $query;
 } else {
 if ( is_post_type_archive('portfolio') && !empty( $query->query['post_type'] ) && $query->query['post_type'] == 'portfolio' ) {
 $query->set( 'posts_per_page', -1 );
 }
 return $query;
 }
 }
 add_filter( 'pre_get_posts', 'wpse63424_filter_pre_get_posts' );

http://wordpress.stackexchange.com/a/63481/74358