[Resolved] List authors is listing admin multiple times
I am working on a author page that will list my authors along with some info on them. Tho code is partially working. The problem is now that i have 5 “users” and it recognizes that – but it adds the profile of the admin 5 times instead.
<?php // Get the authors from the database ordered by user nicename global $wpdb; $query = "SELECT ID, user_nicename from $wpdb->users ORDER BY user_nicename"; $author_ids = $wpdb->get_results($query); // Loop through each author foreach($author_ids as $author) : // Get user data $curauth = get_userdata($author->ID); // Get link to author page $user_link = get_author_posts_url($curauth->ID); // Set default avatar (values = default, wavatar, identicon, monsterid) $avatar = 'wavatar'; ?> <?php wp_list_authors ?> <small style="visibility:hidden; font-size:1px;">Line Break</small> <?php echo get_avatar( get_the_author_email(), '50' ); ?> <p><b><?php the_author_link(); ?></b> <small>(<?php the_author_posts(); ?> Articles)</small></p> <p><?php the_author_description(); ?></p> <?php endforeach; ?>
Any help would be greatly appreciated!!
Don’t know why you would need this:
<?php wp_list_authors ?>
Can only guess that’s causing the admin user to be listed and you have it in a foreach loop.
I took it out and noting changed.
Here is a link to the site not sure if that will help! it is just on a test server now, but i really need to figure this out bc it is moving soon to the real deal!
any other ideas?
Please paste all the code from the theme template file that is displaying those posts into a pastebin, such as wordpress.pastebin.ca, and report the link back here. Maybe someone can spot your problem. Thanks.
Pastebin link: http://wordpress.pastebin.ca/1656467
here you go this is what i used on my page
<?php wp_list_authors('show_fullname=1&exclude=admin'); ?>
works like a charm , let me know if you have any problems
thanks! I have had that previously. I am looking for a more beefed up version. I am needing the avatar and authors bio with it. Not just a list of names!
You can see here what i am going for and my problem.
thanks for the help!
That template you are using looks like it was intended to be a Page template that displayed the title/content of a Page and listed the authors.
So each user was being list over again because of a loop. I’ve commented out (with a //) the lines you don’t need. You may want to uncomment (delete the //) this line <?php //include (TEMPLATEPATH . “/breadcrumb.php”); ?> to show your breadcrumb.
hey! thanks! the pastebin looks exactly the same to me… i might be missing something.. is there something i need to click to see what you have done? I have never used pastebin before.
I am so sorry… you are being so helpful.. and i am just not understanding.. i am very sorry. I am still new with php and wordpress and well codes in general.
Sorry, I used your pastebin link. It should be http://wordpress.pastebin.ca/1656539
cool! well it is a start! it looks like this. so it is getting the different authors.. just in a odd way 😛
Since this is so troublesome.. is there a way i can just manually link in the profiles?
like this for example (just my thoughts.. i know it is not valid)
<?php echo get_avatar(admin, '50' ); ?> <p><b><?php the_author_link(); ?></b> <small>(<?php the_author_posts(); ?> Articles)</small></p> <p><?php the_author_description(); ?></p> <br /> <?php echo get_avatar(cynthia, '50' ); ?> <p><b><?php the_author_link(); ?></b> <small>(<?php the_author_posts(); ?> Articles)</small></p> <p><?php the_author_description(); ?></p>
If something like this would be easier.. i have no problem adding this to the code when i have a new author.. as it is not going to be very often that I add one.
thanks again for all your help!
Oh darn, delete this line:
echo "<pre>"; print_r($author_ids); echo "</pre>";
oh AMAZING! you are my new hero!
thank you so much! the girls are going to be soo happy!
wp_list_authorsis a hell of a lot slower then
Which is somewhat disappointing because
get_users_of_blogactually returns more useful data..
wp_dropdown_userswas slightly slower then
get_users_of_blogwhen preg_matched to extract IDs..
Havn’t tested, but you may wish to look at.
..for grabbing user data, that way you specify the fields you want, rather then grabbing a complete user object with all fields.
It may be slower (could also be faster), no idea, i didn’t test for that, was simply curious of speed comparison between
Good call on
- The topic ‘[Resolved] List authors is listing admin multiple times’ is closed to new replies.