Don’t run a new query in the template, modify the main query before it’s run via the pre_get_posts
action in the theme’s functions.php
file.
function wpd_author_query( $query ) {
if ( $query->is_author()
&& $query->is_main_query() ) {
// your code to set $current_user_name here
$query->set( 'meta_key', '_writer_relation_added_date_' . $current_user_name );
$query->set( 'orderby', 'meta_value_num' );
$tax_query = array(
array(
'taxonomy' => 'writer',
'field' => 'name',
'terms' => $current_user_name
)
)
$query->set( 'tax_query', $tax_query );
// EDIT
// unset the requested author
unset( $query->query_vars['author_name'] );
}
}
add_action( 'pre_get_posts', 'wpd_author_query' );
You can then run the vanilla loop in the default author template, and save an extra query in the process.