Change total number of posts in WordPress archive pages using pre_get_posts

function change_total_posts_archive($query) {
	if (!is_admin() && $query->is_main_query() && $query->is_archive) 
		$query->query_vars['posts_per_page'] = 10; 
	return $query; 
add_filter('pre_get_posts', 'change_total_posts_archive'); 
Need a helping hand in fixing your website issues?

If you are facing any problems in implementing these code snippets and tutorials, you can hire us to fix your website issues.

Hire Us