Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have built a wordpress theme in which I have listed employees of the organization via custom post type. And I am displaying each employee via custom post type.

The employees listed are authors in my website too and they regularly write posts. When I am viewing each employees Profile page, I want to show the lst post written by that employee.

I hope I am clear in my explanation.

Please help me...

share|improve this question

1 Answer 1

You can use the following code to get the most recent post by a given Author, just un-comment one of the two lines as appropriate. See the Codex for more info on WP_Query.

The Codex entry is pretty long, so scroll down to the Parameters section for more info on the various options you can filter your query with.

$query = new WP_Query(array(

    // get most recent post by Author's nickname (not username!)
//    'author_name'    => 'Joe'

    // get most recent post by Author's ID
//    'author'         => 7,

    'posts_per_page' => 1,
));
share|improve this answer
    
Getting author's post is easy....but what I want is completely different. Let me clarify my question again: I am showing employee's profile in my site via custom post type. So when I am viewing an employees profile page (which is not via author.php), I want to show the latest post written by him....assuming that employee is an author on the site. –  Ajay M Feb 5 '13 at 7:19
    
@AjayM, please, add details to the Question itself. As you can see, it was already misinterpreted... Myself, I inderstood you were talking about /wp-admin/profile.php. Show your code, template name, etc. –  brasofilo Feb 5 '13 at 19:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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