Forums

List Authors, but not certain roles. (4 posts)

  1. willGoldstone
    Member
    Posted 3 years ago #

    Hi all, I use this function in my code to list the authors on my site, and their respective rss feeds..

    http://codex.wordpress.org/Template_Tags/wp_list_authors

    But I don't want ALL users listed - only the writers of the site - we also let the public write for the site but I dont want them to appear in the list - how can I restrict this list by role - the only parameter for exclusion appears to be exclude_admin.

    Any help massively appreciated!

    Cheers

    Will

  2. willGoldstone
    Member
    Posted 3 years ago #

    Hi all - i've now realised i'll probably have to edit one of the includes to get this feature - a file called author-template.php.

    on line 448 you'll see

    $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name");

    But I want to get rid of other types of users by excluding not simply the admin, but 'public' user types also. I've tried altering that line to this -

    $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' AND 'public " : '') . "ORDER BY display_name");

    and I also tried this -

    $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'public' " : '') . "ORDER BY display_name");

    and this -

    $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login == 'public' " : '') . "ORDER BY display_name");

    None of which has worked so far. HELP!

    Will

  3. lynettechandler
    Member
    Posted 3 years ago #

    Hi Will, maybe the List Authors Plus plugin will help http://wordpress.org/extend/plugins/list-authors-plus/

  4. jcow
    Member
    Posted 3 years ago #

    I was looking for something similar. That plugin looks perfect for me. Thanks Lynette!

    Will. I had done what you did previously by editing the author template file. But everytime I upgraded, it would mess me up and I would have to do it again. So I would recommend trying to use a plugin. Editing core files is such a last resort.

Topic Closed

This topic has been closed to new replies.

About this Topic