X

How to Display All Subscribers in an Unordered List

Snippets by IsItWP

Are you looking for a way to display all subscribers in an unordered list? While there’s probably a plugin for this, we have created a quick code snippet that you can use to display all subscribers in an unordered list in WordPress.

Instructions:

All you have to do is add this code to your theme’s index.php file:

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

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 10 best WordPress table plugins to organize data and how to create a guest post submission form in WordPress.

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!