Hi I have a custom taxonomy with a term meta flag called 'is_live' set up and I want to exclude all the terms where this flag is false when I call wp_dropdown_categories.

I've checked the codex but cant see anything relating to terms meta.

Anyone have any ideas or tried this before?

  • You can do it with a filter on list_terms_exclusions. Example on that link, just adjust the ID to represent the applicable ID in place of the default category code.
    – t31os
    Nov 29, 2011 at 16:30

1 Answer 1


There is no direct way, hence you'll have to hack it. wp_list_categories calls get_terms internally. There's a filter terms_clauses which will allow you to modify the WHERE conditions for getting the terms. Here's how you can use it:

    add_filter('terms_clauses', 'term_filter', '', 1);

    function term_filter($pieces){

        //echo "<pre>";
        //echo "</pre>";

        //You can change the entire SQL by examining the pieces array
        $pieces['where'] .= '<SQL to get the term meta>'; 

        return $pieces;

    //Here's how $pieces looks like:
        [fields] => t.*, tt.*
        [join] => INNER JOIN wp313_term_taxonomy AS tt ON t.term_id = tt.term_id
        [where] => tt.taxonomy IN ('category') AND tt.count > 0
        [orderby] => ORDER BY t.term_id
        [order] => ASC
        [limits] => 

Append your WHERE condition to the default WHERE condition. I'm not very good with SQL (honestly, I couldn't find where term meta is stored!) hence didn't write the query. For more reference you can check the file taxonomy.php (line. no. 1311) and these 2 posts: Link 1, Link 2.

Hope it helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.