WordPress – Filter by Taxonomy

Something weird happening in my query and can’t see what’s wrong
I am passing the variable THEME from a select list.
THe theme is pulled from the taxonomy THEME

so my code looks like

Read More
$thetheme = $_GET['theme'];`

$thetheme is correctly passed from URL

then

$args2 = array(
     'tax_query' => array(
     array(
         'taxonomy' => 'theme',
         'field' => 'slug',
         'terms' => $thetheme
         )
     ),
     'post_type' => array( 'post', 'dvd' ), 
     'cat' => '31',
     'paged' => $paged, 
     'posts_per_page' => $listitems,
     'order' => 'DESC',
     'orderby' => 'date', 
     'query' => $wp_query
);`

The query is working only on some Post, not all of them, and cant understand why.
If I select a post with the Theme “Adventure” for example, it will pull the correct amount of post.
But an other post, in the same category with a different theme, will not be displayed.

This is puzzling me….

HElP!

thx

Related posts

Leave a Reply

1 comment

  1. Don’t think you need here to run complete taxonomy query… try this =)

     $args2 = array(
          'theme' => $thetheme,
          'post_type' => array( 'post', 'dvd' ), 
          'cat' => '31',
          'paged' => $paged, 
          'posts_per_page' => $listitems,
          'order' => 'DESC',
          'orderby' => 'date', 
          'query' => $wp_query
     );