Tag Archives: exclude_author

wp_list_authors exclude one or multiple users based on name or userid

Skip to about 1:50 – the first part i thought i cut out, but i didn’t, so the first part is just rambling.

So currently (at the time of this video) wordpress doesn’t allow you to exclude specific authors based on id, so i found a fairly easy work around to make it happen for me.

These changes take place in the wp-includes folder / which means with every site upgrade these changes will be erased.
OTHER Notes: You may have to replace the “‘” characters when you copy the code or get a parse error.

firstly here is the code we’re talking about

wp_list_authors(‘exclude_author=1&show_fullname=1&optioncount=1&orderby=post_count&order=DESC&hide_empty=1’);

Found in the wp-includes folder / author-template.php

If you want to exclude the admin from the list of authors, but you’re user isn’t named “admin” all you have to do is find the line of code:

if ( $exclude_admin && ‘admin’ == $author->display_name )

Somewhere around line 298

If you’re like me and you wanted to exclude multiple authors from the list, then what i did to accomplish that was:

Just after this code:

$author = get_userdata( $author_id );

and before this code:

if ( $exclude_admin && ‘admin’ == $author->display_name )

I added this if statement:

// begin that jon jackson’s code
if (($author_id == ‘1’) or ($author_id == ‘6’)){

// These two numbers were the id numbers of my two authors that i didn’t want to display

}else{ // continue original code

Around line 373 (for me), just before this line of code:

$return = rtrim($return, ‘, ‘);

i closed the if statement checking for those user ids

} // end that jon jackson’s code