Support

Account

Forum Replies Created

  • I tried both leanda version and Florian version – none worked. I got no error, just category is still visible in frontend form. 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?

  • Hi,

    I would appreciate help. I tried above solution with small modyfication – I want to exclude one category from front-end form, category ID is 158, acf field slug – tematyka
    I put it on the functions.php of my theme:

    function blokada_kategorii( $args, $field, $post_id ) {
    $args[‘exclude’] = ‘158’;
    return $args;

    }

    add_filter(‘acf/fields/taxonomy/query/name=tematyka’, ‘blokada_kategorii’, 10, 3);

    And I get error:
    Parse error: syntax error, unexpected ‘=’, expecting ‘,’ or ‘)’ in [shortened]/functions.php on line 202
    Line 202 is where add_filter… is

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

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