How to show all members on Member Listing page

By default, the Member Listing page will display a number of members follow the option Blog pages show at most in Settings > Reading. You can go here to change the number as you want, but the option applies to all archive layouts such as blog, category, etc pages

So how to only change the number of members displayed on Member Listing page without changing other archive pages is a question of many customers. Please follow these steps to solve it:

  • Step 1: Please make sure the University Child theme is installed & activated.
  • Step 2: Add this custom code to function.php file of the child theme. Then you can control the number of how many members will be displayed on Member Listing page:
    //Custom Code to shows how many members as you want
    function list_all_members( $query ) {
     if(($query->query_vars['post_type'] == 'u_member') && $query->is_main_query()){
            $query->set('posts_per_page', -1 );
        }
    }
    add_action( 'pre_get_posts', 'list_all_members' );
  • NOTE: -1 is to display all members, you can enter another number as you want.