Search code examples
phpwordpressbuddypress

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


In BuddyPress, 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 website with 112 members, I would expect there to be a total of 6 pages to the members directory. This will obviously change as new members join the site.

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


Solution

  • Try this snippet:

    <?php echo round((int)bp_get_total_member_count()/(int)get_option('posts_per_page'));?>