I’m trying to query all posts by an author and paginate them on the author.php page. I’ve tried messing with the WP default blogs per page settings and that doesn’t help. I’ve looked at other posts on here and could find a solution either. This works on my category pages and custom template pages (with the exception of the author attribute).
Here’s what I have for my query:
if (get_the_author_meta( 'ID' )) {
$authorID = get_the_author_meta( 'ID' );
}
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'post',
'author'=>$authorID,
'orderby'=> 'date',
'showposts'=>'5',
'paged'=>$paged
);
$query = new WP_Query( $args );
I even tried query_posts() with no luck.
The query itself works, but the pagination breaks. Any ideas?
There is already a query on that page.
author.php
is an optional template file that, if present, WordPress will use for author archives. You shouldn’t have to create another query on that page. I think that your query and the native query are colliding, at least in part because both queries will be using the samepaged
query var.If you need to change something about the query, you should probably be interrupting the main query for that page instead of creating a new query.