Home Forums Backend Issues (wp-admin) Exclude taxonomy terms from wp-admin


Exclude taxonomy terms from wp-admin

  • I’m a bit out of my element here, but I need to exclude an entire group of terms from a taxonomy select in the wp-admin.

    Here’s the ACF setup:

    And here’s what it looks like in the editor:

    Here’s the code I’m trying to use to exclude a taxonomy (based on this post):

    function my_taxonomy_query($args, $field){
        $terms = get_terms(['taxonomy' => 'yst_prominent_words', 'hide_empty' => true]);
        $args = $terms; //the IDs of the excluded terms
        return $args;

    I suspect I’m grossly misunderstanding something, because even if I set $args=0, the entire list of terms still populates.

    Can someone point out where I’ve gone wrong?



    (Apologies if this is a duplicate post. I tried to edit it and it disappeared).

  • The value of $args is the same thing you’re using in $terms = get_terms(['taxonomy' => 'yst_prominent_words', 'hide_empty' => true]); what you need to return here is the arguments that ACF will use when it calls get_terms().

    But if you only want to show terms in a single taxonomy why not just set that taxonomy in the Filter by Taxonomy setting for the field?

  • Thanks, John. To answer your question, this has to do with an apparent bug in ACF, where it hooks into the taxonomies generated by the Yoast SEO plugin. I’m trying to exclude those from loading in the back-end to offset a pretty massive performance hit.

    I just discovered that I may be using the wrong filter anyway — I should be using acf/fields/relationship/query.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Exclude taxonomy terms from wp-admin’ is closed to new replies.