0

I just want to get the most latest posts by an author. I am using get_posts at the moment but I notice it doesn't take an author argument, so how I can I specify my author?

$args = array( 'numberposts' => '1');
$posts=get_posts( $args );
foreach($posts as $post)
{                           
    setup_postdata($post);
    //do stuff
}

2 Answers 2

0

$args = array( 'author' => 1, 'numberposts' => 1 ); The author parameter isn't documented on the get_posts() codex page, but it does work.

0

Quick google reveals http://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters

Look at using wp_query() with author parameters and a limit of 1 post.


Note to editors: don't complain about me putting a link instead of typing the answer. I realise is is normally needed in case the link disappears, but since it is a link to the codex, this website will disappear before that link stops working. Peace.

3
  • 1
    $args = array( 'author' => 1, 'numberposts' => 1 ); The author parameter isn't documented on the get_posts() codex page, but it does work. Commented Sep 6, 2012 at 3:17
  • @developdaly this worked. Thank you. DO you want to put this comment as an answer and I will mark it correct?
    – Claire
    Commented Sep 6, 2012 at 8:30
  • @developdaly please type that as an answer so I can complete this qustion
    – Claire
    Commented Sep 24, 2012 at 10:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.