WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm building a custom author.php template. I use this to get the author by slug

$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));

Now my loop uses the author's ID like this

<div class="author-products">
$args = array( 'post_type' => 'product', 'author_id'=> $curauth->ID );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
    <li><div class="author-product-title"><a href="<?php echo get_permalink( $loop->post->ID ) ?>">
        <?php the_title(); ?></a></div>
         <?php if ( has_post_thumbnail()) : ?>
            <a class="author-product-thumb" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
            <?php the_post_thumbnail('thumbnail'); ?>
        <?php endif; ?>
<?php endwhile; wp_reset_query();?>
<div class="clear"></div>

The loop is displaying all the posts and not filtering, is it a problem in the arguments?

share|improve this question
up vote 1 down vote accepted

Try 'author' => $curauth->ID instead of 'author_id'=> $curauth->ID since author_id is not a valid parameter.

share|improve this answer

Your Answer


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.