Do not use query_posts
, and for that matter any custom query to replace the main query. It is always problematic and it creates more problems that solving it.
Use the main query and make use of pre_get_posts
to alter the main query as needed.
To solve your issue, remove the query_posts
line, this is how author.php should look.
<?php
if(isset($_GET['author_name'])) :
$curauth = get_userdatabylogin($author_name);
else :
$curauth = get_userdata(intval($author));
endif;
?>
<h2>Campaigns by <?php echo $curauth->nickname; ?>:</h2>
<?php
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li>
<a href="https://wordpress.stackexchange.com/questions/175597/<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
<?php the_title(); ?></a>,
</li>
<?php endwhile; else: ?>
<p><?php _e('No posts by this author.'); ?></p>
<?php endif; ?>
Add the following in your functions.php
file
add_action( 'pre_get_posts', function ( $q ) {
if( !is_admin() && $q->is_main_query() && $q->is_author() ) {
$q->set( 'posts_per_page', 100 );
$q->set( 'post_type', 'campaigns' );
}
});
This should solve your issue