logo

$15
List of Author Boxes

Hi!

I want to have a page with a list of all the authors of the website. Instead of having just a list I want to have:

Image of the author (I'm using User Photo plugin not avatars)
Name of the author
Description of the author
Link to the author's archive of text


I don't want to list either the admin nor the contributors, just the authors.

I found this code, but I coulnd't make it work:
http://bavotasan.com/tutorials/how-to-display-an-author-list-with-avatars-in-wordpress/

Thanks!

Olivia | 02/26/10 at 11:56am | Edit


(2) Possible Answers Submitted...

  • avatar
    Last edited:
    02/27/10
    10:58am
    Dan Fraticiu says:

    Put this into your function.php


    function authors_list_shortcode_handler($atts, $content=null){

    global $wpdb;

    $authors = $wpdb->get_results( "SELECT ID, user_nicename from $wpdb->users ORDER BY display_name" );

    $content = '';
    foreach($authors as $author){

    $content .='<div id="colaborador">';

    $content .= userphoto($author->ID);
    $content .= '<div id="titulocolaborador">'.get_usermeta($author->ID, 'first_name').' '.get_usermeta($author->ID, 'last_name').'</div>';

    $content .= '<div id="textocolaborador">'.get_usermeta($author->ID, 'description').'</div>';

    $content .= '<a href="'.get_author_posts_url($author->ID, $author->user_nicename).'">Link</a>';

    $content .= '</div>';
    }

    return $content;

    }
    add_shortcode('authors_list','authors_list_shortcode_handler');



    Then use this [authors_list] where you wnat to display the list.

    I'm don't know if the photo will work, I haven't test it as I don't have that plugin installed but everything else shold be fine.

    Previous versions of this answer: 02/27/10 at 2:16am

    • 02/26/10 6:49pm

      Olivia says:

      Hi Dan,

      Thanks for answering.
      This is giving error:
      .userphoto

      Everything else work great
      I'm using the plugin because some of the writers prefer to email their picture to me than to create their avatar by themselves. Can you think in how to solve this?

    • 02/27/10 2:17am

      Dan Fraticiu says:

      I've updated the code, and I tested it. You should have no more problems.

    • 02/27/10 10:57am

      Olivia says:

      Thanks Dan,

      It works perfectly!

  • avatar
    Last edited:
    02/27/10
    10:58am
    Nathaniel Usarzewicz says:

    So, in function.php copy/paste this code:


    function my_list_authors() {
    global $wpdb;

    $authors = $wpdb->get_results("SELECT * from $wpdb->usermeta WHERE meta_key = 'wp_capabilities' AND meta_value = 'a:1:{s:6:\"author\";b:1;}'");

    foreach ( (array) $authors as $author ) {
    $author = get_userdata( $author->user_id );
    $userlevel = $author->wp2_user_level;

    $name = "$author->first_name $author->last_name";
    $the_description = $author->description;
    $author_id = $author->ID;

    $file = get_option('home') . '/';
    $the_link .= $file . '?author=' . $author_id;

    ?><li><?php echo '<a href="' . $the_link . '" title="' . $name . '">';?><?php echo userphoto($author_id, '', '', array(style => 'width:100px;height:100px;'), get_template_directory_uri() . '/default-avatar.gif'); ?><br /><span class="authors_displayname"><?php echo $name; ?></span></a><br /><?php echo $the_description; ?></li>
    <?php
    }
    }


    Then create page template (how-to on Codex) and within WordPress loop paste this function:


    <ul>
    <?php my_list_authors(); ?>
    </ul>


    This will display all authors (people with author rank) from your WordPress with userphoto, name, description and it will all be wrapped into link to author's archive, and it will also display default avatar from your template folder :)

    Previous versions of this answer: 02/26/10 at 3:51pm | 02/26/10 at 3:52pm

    • 02/26/10 6:55pm

      Olivia says:

      Hi Nathaniel,
      Thanks for your response.
      I can't make your code work.
      The page is blank: http://www.olivialiendo.com/marcapasos/colaboradores-2/

    • 02/27/10 4:19am

      Nathaniel Usarzewicz says:

      Then try this, find:

      'a:1:{s:6:\"author\";b:1;}


      and change to:

      'a:1:{s:10:\"author\";b:1;}


      If this doesn't work, please take a look at your database -search usermeta table, look for wp_capabilities like this a:1:{s:6:\"author\";b:1;} - that 'author' part is what really matters, when you find it, copy and paste into the code as I said (replace a:1:{s:6:\"author\";b:1;}) with it, and it should work.

    • 02/27/10 10:59am

      Olivia says:

      Thanks for your help Nathaniel,
      I'll have you in my mind next time that I need some help.

This question has expired.





Current status of this question: Completed