Using tax_query returns nothing (1 post)

  1. vk011
    Posted 2 years ago #

    I am making a custom search which taps into the regular WP search query, it all works well so far (for example I can choose which category to exclude / include), BUT I also want it to search by taxonomy term.

    I have 5 posts with a string 'welcome' within them. If I search for 'welcome', I get 5 results (correct).

    Now, I made a new taxonomy called 'location', and I added a term called bg to it, and then I added bg to ONE of my posts, and I placed the following inside my query:

    $taxquery = array(
                    'taxonomy' => 'location',
                    // 'field' => 'bg'
                    'terms' => 'bg'
                    // 'operator'=> 'AND'
    $query->set( 'tax_query', $taxquery);

    but it returns 0 results, whereas I expected it to return 1 result. I also tried enabling the field param and disabling terms param but I get the same thing.

    I also noticed that even if I just change location to category and don't use any extra params (such as field terms or something else), I still get 0 results returned!

    Is this normal?

Topic Closed

This topic has been closed to new replies.

About this Topic