It is not advised to run custom queries in place of the main query. What you are trying to do is already done by the main query. In short, you are trying to reinvent the wheel :-).
Your no 1 solution would be to return to the default loop, and apply changes to the main query through pre_get_posts
. Check this post for more info
Just on your code, you are passing the term name to your terms
parameter, where as you should be passing the term slug as you have set your field
to slug
. Also, your tax_query
should be an array of an array. Change your code to
$the_query = new WP_Query( array(
'post_type' => array('newsbox_post'),
'tax_query' => array(
array(
'taxonomy' => $term->taxonomy,
'field' => 'slug',
'terms' => $term->slug,
),
),
) );