In order to do this outside of the Loop, you may want to try using multiple query posts: http://codex.ww.wp.xz.cn/Template_Tags/query_posts#Author_Parameters
Cool thanks, that looks like it will do the trick. Could I use this multiple times on one page? For example I want to use it 8 times on a page for 8 different authors.
It depends on where you plan to use this page. Perhaps you better use WP Query since you need 8 of them.
For example, here’s how you would set it up to show two different author’s pages:
<?php
$args = array(
'author' => 1,
'showposts' => 3,
'orderby' => title,
'order' => ASC
);
$author1 = new WP_Query($args); ?>
<ul>
<?php if (have_posts()) : while ($author1->have_posts()) : $author1->the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
<?php else: endif; ?>
<?php
rewind_posts();
$args = array(
'author' => 2,
'showposts' => 3,
'orderby' => title,
'order' => ASC
);
$author2 = new WP_Query($args); ?>
<ul>
<?php if (have_posts()) : while ($author2->have_posts()) : $author2->the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
<?php else: endif; ?>
Thanks for all your help mmuro, I really appreciate it. Unfortunately I’m struggling to get this working, even with your provided code (which was great thanks, explain a few things for me).
This is the page I’m trying to build – http://code.pitch.net.nz/adm/005/blogs.html – this is being pulled by using category-3.php – There’s 8 people on this blog and for each of them I want to pull their 3 latest posts, the rest of the information is static.
However if I put your code in, it doesn’t return any results (author id 1 has two posts assigned to it). I’m digging through codex but can’t really find what I want.
Thanks again for your help.
The author ID’s you see in that code(1 & 2) are just examples. You should go to the Users list in your admin panel and find out the IDs for each author.
All you have to do is click on the name and copy the “user_id=” number.
So, where you see in that array that 'author' => 1, you will change the 1 to whatever numbers you find. Make sense?
Yep, I understood the ID bit, both id’s 1 and 2 exist and have posts written by them but it’s still not returning any results. Should that code work right off the bat or do I need to do something else?
Again, thanks for all the help.
<?php
$lastposts = get_posts('numberposts=3&author=2');
foreach($lastposts as $post) : setup_postdata($post); ?>
<li><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
Turns out I can do it just like that! I think I was over complicating things. Cheers mate.