If you have a lot of posts on your WordPress site, and you want to limit total posts in the admin area when you need to limit posts in functions.php adding this peace of code.

  • Custom WP


function my_post_queries( $query ) {
if (is_admin() && $query->is_main_query()){
if(is_admin()){
$query->set('posts_per_page', 3);
}
if(is_category()){
$query->set('posts_per_page', 3);
}
}
}
add_action( 'pre_get_posts', 'my_post_queries' );

Custom Function Custom WordPress
Custom WordPress