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.

Hi to the community!!!

I need some help with pagination in author.php template.
I have pagination working in all my loops except in authors.php that i get a 404 error.
In my settings/reading i have set blog posts to show as 1.

The first step was the author rewrite from author to artist,

function set_new_author_base() {
    global $wp_rewrite;
    $author_slug = 'artist';
    $wp_rewrite->author_base = $author_slug;
}
add_action('init', 'set_new_author_base');

In the author.php template i query the $author-ID posts in the custom post type 'ideas':

<?php 
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
query_posts('post_type=ideas&author='.$curauth->ID.'&posts_per_page=1&paged='.$paged);
if(have_posts()) : while(have_posts()) : the_post(); ?>
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php endwhile;
previous_posts_link('newer');
next_posts_link('older');
endif;
?>

for some reason i get a 404, in the other side, i can run queries in taxonomy.php, home.php, index.php... with pagination also and it works fine.

i see the next and previous links that point me here: http://domain.dev/artist/philip/page/2/ but i get the 404 error,

the query in home.php template:

<?php //*The Query*//
query_posts($query_string . '&post_type=ideas&posts_per_page=1&offset=0&paged='.$paged);
if(have_posts()) : while(have_posts()) : the_post();
?>

here i correctly get next and previous posts http://domain.dev/ideas/page/2/

the query in index.php template:

<?php //*The Query*//
query_posts($query_string . '&posts_per_page=1&offset=0&paged='.$paged);
if(have_posts()) : while(have_posts()) : the_post();
?>

here i correctly get next and previous posts http://domain.dev/ideas/page/2/

do you understand what is going on here???
i'm sure that the author have some posts, i have flush the rules...

thanks a lot!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

i found a solution to my problem!

function custom_author_archive( &$query ) {
    if ($query->is_author)
        $query->set( 'post_type', 'idea' );
}
add_action( 'pre_get_posts', 'custom_author_archive' );
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.