I am using the theme TwentyTwelve and modified the standard post query in the file author.php with the following code:
function wpd_author_query( $query ) {
//CODE to set $current_user_name here
//This gets the author from the URL
$author = get_user_by('slug',get_query_var('author_name'));
$current_user_name = $author->user_nicename;
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' );
$query->set( 'post_status', $post_status );
$tax_query = array(
array(
'taxonomy' => 'writer',
'field' => 'name',
'terms' => $current_user_name
)
);
$query->set( 'tax_query', $tax_query );
}
}
add_action( 'pre_get_posts', 'wpd_author_query' );
However, the tax_query is not working for the author page. It is still not retrieving the posts in the writer taxonomy.
I did try applying that code for other pages such as is_home() is_archive() and it does work.
So, there must be a conflict in with wordpress and the author template page that is not allowing me to use the tax_query for retrieving posts in the writer taxonomy.