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'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">
<ul>
<?php
$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'); ?>
            </a>
        <?php endif; ?>
    </li>
<?php endwhile; wp_reset_query();?>
</ul>
<div class="clear"></div>
</div>

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

share|improve this question

1 Answer 1

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

 
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.