I solved this issue using pre_get_post. I found one implementation that works for me:
if ( ! function_exists( 'ucc_add_cpts_to_pre_get_posts' ) ) {
function ucc_add_cpts_to_pre_get_posts( $query ) {
if ( $query->is_main_query() && ! is_post_type_archive() && ! is_singular() && ! is_404() ) {
$my_post_type = get_query_var( 'post_type' );
if ( empty( $my_post_type ) ) {
$query->set('post_type', 'your_custom_type');
$query->set('posts_per_page', 'your_posts_per_page');
}
}
}
}
add_action( 'pre_get_posts', 'ucc_add_cpts_to_pre_get_posts' );
http://uncommoncontent.com/2012/01/28/add-custom-post-types-to-the-loop You must remove query_posts from your template.