WordPress.org

Ready to get started?Download WordPress

Forums

User Photo
Display list of 8 user photos on home page, outside the loop (3 posts)

  1. chrisjb
    Member
    Posted 1 year ago #

    Hi,

    I am trying to display a list of users, set by ID. I have used this to achieve it:

    <?php
                //display selected users
                $userids_to_display = array(11,7,12,13,5,6,9,8); // wordpress user IDs to include
                $blogusers = get_users_of_blog();
                if ($blogusers) {
                  foreach ($blogusers as $bloguser) {
                    if ( in_array($bloguser->user_id, $userids_to_display) ) {
                      $user = get_userdata($bloguser->user_id);
                      echo '<div class="expert-author">';
                      echo '<div class="thumbnail">'.userphoto_the_author_photo($user->ID).'</div>';
                      echo '<h4>' . $user->user_firstname . ' ' . $user->user_lastname . '';
                      echo '<p>'.$user->description.'</p>';
                      echo '</div>';
                    }
                  }
                }
                ?>

    I think I'm close to getting the photos to display for each user, but not quite there.

    Please could you tell me what I can do to make the user photos display?

    Thank you very much for your help.

    Chris

    http://wordpress.org/extend/plugins/user-photo/

  2. chrisjb
    Member
    Posted 1 year ago #

    Bump

  3. chrisjb
    Member
    Posted 1 year ago #

    Unfortunately the User Photo plugin didn't work for this so in the end I stuck to good old Gravatar, which works perfectly. Here's is the code I used in the end, with links to author pages as well:

    <?php
    	    //display selected users
    	    $userids_to_display = array(11, 7, 12, 13, 5, 6, 9, 8); // wordpress user IDs to include
    	    $blogusers = get_users_of_blog();
    	    if ($blogusers) {
    		foreach ($blogusers as $bloguser) {
    		    if (in_array($bloguser->user_id, $userids_to_display)) {
    			$author_url = get_author_posts_url($bloguser->user_id);
    			$user = get_userdata($bloguser->user_id);
    			echo '<div class="expert-author">';
    			echo '<a href='.$author_url.'>';
    			echo '<div class="thumbnail">' . get_avatar($user->ID) . '</div>';
    			echo '<h4>' . $user->user_firstname . ' ' . $user->user_lastname . '</h4></a>';
    			$args = array(
    			    'author' => $user->ID,
    			    'post_type' => 'post',
    			    'post_status' => 'publish',
    			    'posts_per_page' => 1,
    			    'caller_get_posts' => 1
    			);
    			$my_query = null;
    			$my_query = new WP_Query($args);
    			if ($my_query->have_posts()) {
    			    //echo 'List of Posts for ' . user->user_firstname . ' ' . $user->user_lastname;
    			    while ($my_query->have_posts()) : $my_query->the_post();
    				?>
    				<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php echo get_post_meta($post->ID, 'promo_headline', true); ?></a></p>
    				<?php
    			    endwhile;
    			}
    			wp_reset_query();  // Restore global post data stomped by the_post().
    			echo '</div>';
    		    }
    		}
    	    }
    	    ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.