• I’m trying to show a list of posts by an author on the author’s profile page (authors.php template). I’ve come up with this much
    <?php $recent = new WP_Query("cat=5&author=<?php the_author_meta('ID'); ?>"); while($recent->have_posts()) : $recent->the_post();?>
    to begin the loop, which is how all other loops on our site are set up. The only thing that doesn’t seem to be working is the call to author id. I’m using the same method to call the author ID outside of the loop.

    Is there a way to display posts from a specified category from only the author of the page that this loop appears on? I’ve searched the forums for a while and that’s how I found the author= help, but they only say to use author= with the specific ID number…

Viewing 3 replies - 1 through 3 (of 3 total)
  • Using the Author Template, Sample Template File, just put this:

    <?php
    query_posts($query_string . '&cat=1');
    ?>

    right before this:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    Of course change the cat=1 to whatever category ID you are displaying.

    Thread Starter thelocallanding

    (@thelocallanding)

    That only seems to show the page that the loop appears on… I set it to category 5, but it showed that author’s profile page, and said it was filed under ‘Uncategorized’.

    It does seem to pull posts by the right author, but that’s about it. I’m out of ideas.

    Works okay for me using the WordPress Default theme with no plugins active.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Posts by Category and Author’ is closed to new replies.