• Resolved jarvo1980

    (@jarvo1980)


    Hi All,

    I’ve got the following code which creates the author page I want (listing all authors). Problem is, I can’t get it to list the posts per author, it simply won’t work. What am I doing wrong?

    // 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);
    
    	// If user level is above 0 or login name is "admin", display profile
    		if($curauth->user_level > 0 || $curauth->user_login == 'admin') :
    
    		// Get link to author page
    			$user_link = get_author_posts_url($curauth->ID);
    
    		// Set default avatar (values = default, wavatar, identicon, monsterid)
    			$avatar = 'wavatar';
    ?>
    
    			<a href="<?php echo $user_link; ?>" title="<?php echo $curauth->display_name; ?>">
    				<?php echo get_avatar($curauth->user_email, '96', $avatar); ?>
    			</a>
    
    			<a href="<?php echo $user_link; ?>" title="<?php echo $curauth->display_name; ?>"><?php echo $curauth->display_name; ?></a>
    
    			<?php echo $curauth->aim; ?>
    			<?php echo $curauth->description; ?>
    			<?php echo $curauth->display_name; ?>
    			<?php echo $curauth->first_name; ?>
    			<?php echo $curauth->ID; ?>
    			<?php echo $curauth->jabber; ?>
    			<?php echo $curauth->last_name; ?>
    			<?php echo $curauth->nickname; ?>
    			<?php echo $curauth->user_email; ?>
    			<?php echo $curauth->user_login; ?>
    			<?php echo $curauth->user_nicename; ?>
    			<?php echo $curauth->user_registered; ?>
    			<?php echo $curauth->user_url; ?>
    			<?php echo $curauth->yim; ?>	
    
    			<?php echo $curauth->nickname; ?> wrote <b><?php the_author_posts(); ?></b> articles
    			 it's time to load WP loop and posts title, excerpt and link
    
    			<?php while (have_posts()) : the_post(); ?>
    
    			<a href=”<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
    
    			<small><?php the_time('F j, Y'); ?> <a href="<?php comments_link(); ?>"><?php comments_number('Post a comment','One comment','% comments'); ?></a></small><br />
    
    			Url: <?php the_permalink(); ?><br /><br />
    			<?php endwhile; ?>
    
    		<?php endif; ?>
    	<hr />
    	<?php endforeach; ?>

    Any help is much appreciated!

    TIA

Viewing 1 replies (of 1 total)
  • Thread Starter jarvo1980

    (@jarvo1980)

    Ok, I’ve altered the loop to

    <?php $numposts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status='publish' AND post_type='post' AND post_author = " . $curauth->ID . " ORDER BY post_modified LIMIT 3"); ?>
    
    <ul>
    <?php foreach ($numposts as $numpost) {
    	$link = get_permalink( $numpost->ID );
    	echo '<li><a href="' . $link . '">'.$numpost->post_title."</a></li>";
    } ?>
    </ul>

    It now works

Viewing 1 replies (of 1 total)
  • The topic ‘Author Page Help – Multiple Authors & There posts’ is closed to new replies.