This is expected output from what you have in your code. Never change the main query for a custom query on any archive page or on the home page. Custom queries are always troublesome as the main query is quite specific on these pages.
I would advice you to rather use pre_get_posts
to alter the main query on that specific archive page or home page you want to target, and leave the default loop in place.
Also, your tax query is completely wrong. It should be an array of an array. Please have a look at constructing a tax query in WP_Query
For further reading and a better understanding, please see my answer I recently did on a similar type of question
Sample code (place in functions.php and return to default loop in taxonomy.php):
function custom_author_page( $query ) {
if ( !is_admin() && $query->is_tax( 'post_authors' ) && $query->is_main_query() ) {
$query->set( 'post_type', 'my-post-type' );
$query->set( 'order', 'DESC' );
}
}
add_action( 'pre_get_posts', 'custom_author_page' );
EDIT
From your comments, you have named your taxonomy template taxonomy-post-author.php which relates to taxonomy post
and term author
. Rename your taxonomy template to taxonomy-post_authors.php
EDIT 2
OPTION 1
Change your taxonomy page to just the default loop, no custom loop.
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
//
// Post Content here
//
} // end while
} // end if
?>
Change the main query with pre_get_posts
as above. This is the correct method
OPTION 2
Get the queried term using get_queried_object('term');
, and from that return the slug of the term. PS! this code should be used in taxonomy pages
$queried_object = get_queried_object('term');
$term_slug = $queried_object->slug;
Return $term_slug
to your tax_query
as terms
EDIT 3
To get an a array of term names/slugs/ID’s from a specific taxonomy, use get_terms()
.
$terms = get_terms('post_authors');
$term_names = array();
if ( !empty( $terms ) && !is_wp_error( $terms ) ) {
foreach ( $terms as $key=>$term){
$term_names[$key] = $term->name;
}
}
You can then just simply pass $term_names
to terms
,
'terms' => $term_names
EDIT 4
Use
<pre><?php var_dump($term_names); ?></pre>
to print the array. Output will look like this
array(6) {
[0]=>
string(12) "Admin se pen"
[1]=>
string(11) "Besprekings"
[5]=>
string(12) "Toets Parent"
[6]=>
string(15) "Uit die grapkas"
[7]=>
string(14) "Uit die koskas"
[8]=>
string(11) "Uit my lewe"
}