Custom taxonomy query for a custom post type

Question

I have a custom post type called news with a custom taxonomy called news category. Right now I have a template called taxonomy-news_category-press.php where press is one of the news_categories. The query I’m using is:

$query_args = array(
    'taxonomy'  => 'news_category',
    'term'      => 'press',
    'post_type' => 'news',
)  

I don’t like this though. It’s hard coded and if I change press to something else it will break. I want to replace press in 'term' => 'press' with a variable that will pull in the news_category from the URL so it will be responsive with any news_category. I understand that I’ll need to change the template file to taxonomy-news_category.php when I solve this variable issue.

0
, , Austin 5 years 2016-07-12T14:10:21-05:00 0 Answers 110 views 0

Leave an answer

Browse
Browse