From the info you have given in your post, I believe you are using a custom page.php template here
Here is the the reasons you get the output as stated:
The main query executes on each and every page that is loaded. The main query is very specific for every type of template. $wp_query
is the super global used by the main query
To test the how unique the main query behaves on all the specific templates, add print_r($wp_query);
to all archive pages (archive.php, category.php, author.php etc), index.php and page.php. As you can see, the results are quite different for each instance. To understand how that works, you have to read Query Overview in the codex
OK to come back, the reason why you get the specific output when you use $wp_query
, it displays info from the main query for the page, not info from your custom query.
To get info from your custom query, you have to print_r(VARIABLE USED FOR new WP_Query);
, in your case print_r($author_query)
.
To get pagination to work on your custom query, you have the pass the paged
parameter to your arguments. Also, when using next_posts_link()
, you have to specify the $max_pages
parameter
Here is a working example from the codex. Modify as needed to suite your arguments etc.
<?php
// set the "paged" parameter (use 'page' if the query is on a static front page)
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
// the query
$args = array(
'post_type' => 'post',
'posts_per_page' => 10,
'post_status' => 'publish',
'author_name' => 'admin'
'paged' => $paged
);
$author_query = new WP_Query( $args );
?>
<?php if ( $author_query->have_posts() ) : ?>
<?php
// the loop
while ( $author_query->have_posts() ) : $author_query->the_post();
?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php
// next_posts_link() usage with max_num_pages
next_posts_link( 'Older Entries', $author_query->max_num_pages );
previous_posts_link( 'Newer Entries' );
?>
<?php
// clean up after the query and pagination
wp_reset_postdata();
?>
<?php else: ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
EDIT
This post might also share some more light on the main query and how it works
EDIT 2
I have updated the code to show your specific from your question. Hope this is helpful