Support

Account

Home Forums Front-end Issues Excluding taxonomy from frontend

Helping

Excluding taxonomy from frontend

  • Hi,

    What I try to achieve: exclude category with ID 158 from being visible in frontend form, slug of this field is “tematyka”. So my code is:

    <?php
    add_filter(‘acf/fields/taxonomy/wp_list_categories/name=tematyka’, ‘my_taxonomy_args’, 10, 2);

    function my_taxonomy_args( $args, $field )
    {
    $args[‘exclude’] = array(158); //the IDs of the excluded terms
    return $args;
    }
    ?>

    I tried also without name, to exclude this category from all fields and forms (though I have only one form):

    <?php
    add_filter(‘acf/fields/taxonomy/wp_list_categories’, ‘my_taxonomy_args’, 10, 2);

    function my_taxonomy_args( $args, $field )
    {
    $args[‘exclude’] = array(158); //the IDs of the excluded terms
    return $args;
    }
    ?>

    None worked. What did I wrong? Or is any other method to exclude one category from the field?

  • I have exactly the same question, the filter doesn’t seems to work on front-end. Any solution ?

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

The topic ‘Excluding taxonomy from frontend’ is closed to new replies.