The problem is you aren’t saving your custom query’s results. To do it your way, you would need to save the query’s results to a variable, like so:
$myposts = query_posts( $archive_args );
if ( $myposts->have_posts() ) : while ($myposts->have_posts()) : $myposts->the_post();
However, that’s not the most efficient way. WP runs the default query in addition to this custom one. So, you would be better off using pre_get_posts
to alter the main query and just using its results – meaning you would not need to do a custom query or add the $myposts
part at all.
Your pre_get_posts
filter would just be something simple like:
// If this is the main query, not in wp-admin, and it's for an archive
if($query->is_main_query() && !is_admin() && $query->is_post_type_archive()) {
// Pull 8 posts per page
$query->set('posts_per_page', '8');
}