• Resolved carlosvai

    (@carlosvai)


    Hi! Maybe this is a silly question, but I’m trying to show only child categories.

    I had success implementing a function given by @shabti

    function my_taxonomy_query( $args, $field, $post_id ) { 
        // modify args
        $args['child_of'] = '2144'; //my category ID
        // return
        return $args; 
    }
    add_filter('acf/fields/taxonomy/query/name={$field_name}', 'my_taxonomy_query', 10, 3);

    But I would like to list other categories childs in the same field, not just one.
    I tried things like
    $args['child_of'] = array(2144,2145);
    or
    $args['child_of'] = '2145' , '2144';

    but did not work.

    Any suggestions?
    Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Shabti Kaplan

    (@shabti)

    @carlosvai

    Thanks for the question.

    Change $args[‘child_of’]? to $args[‘parent’]?

    Thread Starter carlosvai

    (@carlosvai)

    @shabti thanks for the help as usual!
    That didn’t work for me.
    But what I end up doing is making a 2-step process.

    1) a “select” field with the parent categories written as choices.
    2) conditional fields for every category that only shows when the above choice matches.

    The code snippet is a little bit of pain to make it, but once you have it it works fine.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘“Child of” function of multiple categories’ is closed to new replies.