WordPress.org

Ready to get started?Download WordPress

Forums

Authors Page (6 posts)

  1. Cupidf007
    Member
    Posted 2 years ago #

    Hi, I would like to create a page in which all the authors name and their bio with their profile pictures should be listed.

    how to do this ?

    P.S I am a beginner to wordpress.

  2. aboelabbas
    Member
    Posted 2 years ago #

    You can list them using these functions:
    get_users()
    get_avatar()

    For example :

    <ul>
    <?php
    $blogulist = get_users();
    foreach ($blogulist as $blogus){
        $uav       = get_avatar($blogus->ID,30,'',$blogus->display_name);
    	$upostsurl = get_author_posts_url($blogus->ID);
        echo '<li><a href="'.$upostsurl.'">'.$uav.$blogus->display_name.'</a></li>';
    }
    ?>
    </ul>
  3. Cupidf007
    Member
    Posted 2 years ago #

    Sorry i dont knw about the coding stuff!! where i have to put this code. I tried by creating author.php and used this code but no use.

  4. aboelabbas
    Member
    Posted 2 years ago #

    The code works just place it where You want to display the list of users in your theme templates.
    For example, place this in the author.php file of twentyeleven theme
    just above this part: </div><!-- #content -->

    <ul>
    <h3>Browse other authors' posts</h3>
    <?php
    $blogulist = get_users();
    foreach ($blogulist as $blogus){
        $uav       = get_avatar($blogus->ID,30,'',$blogus->display_name);
    	$upostsurl = get_author_posts_url($blogus->ID);
        echo '<li><a href="'.$upostsurl.'">'.$uav.$blogus->display_name.'</a></li>';
    }
    
    ?>
    </ul>
  5. ravey
    Member
    Posted 2 years ago #

    Hi Dawn birth,

    With the code provided how do I block certain authors from showing up? I'm guess using their ID's but I dont get how to do it.

    Anyways,
    Thank you

  6. aboelabbas
    Member
    Posted 2 years ago #

    Yes, U can do this depending on their IDs
    Put the IDs which U want to hide in an array, and skip the users in this array from the loop.

    So the previous code will be like this:

    <ul>
    <h3>Browse other authors' posts</h3>
    <?php
    $blogulist = get_users();
    $hide_users = array(1,7,12);
    foreach ($blogulist as $blogus){
        if(in_array($blogus->ID,$hide_users)){continue;}
        $uav       = get_avatar($blogus->ID,30,'',$blogus->display_name);
    	$upostsurl = get_author_posts_url($blogus->ID);
        echo '<li><a href="'.$upostsurl.'">'.$uav.$blogus->display_name.'</a></li>';
    }
    
    ?>
    </ul>

    in this part:$hide_users = array(1,7,12);
    the users with these IDs :"1,7,12" will be hidden from the list.

Topic Closed

This topic has been closed to new replies.

About this Topic