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 am trying to retrieve all custom post types created by the current user.

I have this piece of code:

wp_get_current_user();

$args_my_items = array(
    'posts_per_page' => 10,
    'post_type' => 'mycustomposttype',
    'post_author' => $current_user->ID);

query_posts($args_my_items);

What ends up being returned are all posts of type "mycustomposttype". It does not filter by post_author.

Am I using the wrong query parameters? How can I filter by the current user?

Thanks.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You must specify the author parameter as described here. Try to use:

$args_my_items = array(
    'posts_per_page' => 10,
    'post_type' => 'mycustomposttype',
    'author' => $current_user->ID
);

query_posts($args_my_items);
share|improve this answer
    
Awesome. Thank you. I looked at the post table and I saw a column labeled 'post_author' so i thought that would work. I wonder why the parameter does not match the table column. –  rexposadas Apr 15 '11 at 22: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.