I have used this technique before and cannot work out why this time it is not working.
'news_category' is a custom taxonomy of my custom post type 'News'.
I am getting the taxonomy of the current post (which is custom post type 'news') using get_the_term_list, replacing the spaces with '-' and using the variable in my query.
If I echo the query it gives me the exact string I am expecting - and if I manually enter this string into the query, it works, but the variable doesnt.
<?php $cats = get_the_term_list($post->ID, 'news_category'); ?> <?php $cat = str_replace(' ', '-', $cats);?> <?php $category = strtolower($cat); ?> <?php echo $category; ?> <?php $args = array( 'post_type' =>'news', 'news_categories' => $category, 'post__not_in'=> array($post->ID) ); ?> <?php $sidebar_category = new WP_Query($args); ?>