X

Display all subscribers in an unordered list

Vantage Review

Adding this snippet to your wordpress theme will display all subscribers in an unordered list


<ul>
<?php
    $blogusers = get_users('blog_id=1&orderby=nicename&role=subscriber');
    foreach ($blogusers as $user) {
        echo '<li>' . $user->display_name . '</li>';
    }
?>
</ul>

Comments  Leave a Reply

  1. That’s not a very scalable solution unfortunately. You need to add pagination into it as well as the ‘number’ and ‘offset’ parameters to handle it. From my testing, the get_users() function does not handle well when you have more than approx 1000 results in the query.

    1. I have not tested this snippet with over 1000 subscribers myself so I have to trust you on this one. Without pagination this would be a solution for smaller websites, if you have another solution please feel free to contribute I would be happy to post the solution.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!