Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to get the total number of pages in the members directory?


  • Henry
    Member

    @henrywright-1

    The members directory is split into pages. For example, the first 20 members are displayed on page 1, the second 20 members are displayed on page 2, and so on.

    So, on a site which has 112 members, I would expect there to be a total of 6 pages. This will obviously change as new members join the site.

    Is there a way to get the total number of pages?

Viewing 2 replies - 1 through 2 (of 2 total)

  • Henry
    Member

    @henrywright-1

    Just needed a bit of maths to get this value

    $total = ( bp_get_total_member_count() / $per_page )

    Note, $per_page is whatever you’ve set in your custom members loop. I think the default is 20.

    Then you can do:

    $pages = ceil( $total )


    Henry
    Member

    @henrywright-1

    Just found an even better way of getting the total. This will always match your loop count. e.g be correct even when member search has been used.

    global $members_template;	
    $total = ( (int)$members_template->total_member_count / 2 );
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to get the total number of pages in the members directory?’ is closed to new replies.
Skip to toolbar