Support

Account

Home Forums General Issues Register two locations via php doesn\'t work

Solved

Register two locations via php doesn\'t work

  • Hi,
    I register my acf group via php, but trying to register two locations doesn’t work.
    If I got this currently, this is the way to do this:

    `’location’ => array (
    array (
    array (
    ‘param’ => ‘post_type’,
    ‘operator’ => ‘==’,
    ‘value’ => ‘post’,
    ‘order_no’ => 0,
    ‘group_no’ => 0,
    ),
    array (
    ‘param’ => ‘post_type’,
    ‘operator’ => ‘==’,
    ‘value’ => ‘aran_agencies’,
    ‘order_no’ => 1,
    ‘group_no’ => 0,
    ),
    ),
    ),`

    But I don’t see anything not in “posts” and not in “aran_agencies”.
    But if I register only one, it does work.

    What am I doing wrong?

    Thanks in advance

  • The nesting on your location array is not right

    
    
        'location' => array(
            // each OR group is an array
            array(
              // each location in the group is an array
              array(
                'param' => 'post_type',
                'operator' => '==',
                'value' => 'post',
              ),
              // if you wanted to add an "AND' rule it would go here
            ),
            // this is another OR group
            array(
              array(
                'param' => 'post_type',
                'operator' => '==',
                'value' => 'aran_agencies',
              ),
            ),
          ),
        );
    

    Also, menu order and position are not part of the location, these cannot be set differently for different locations.

    The best way to figure out how to construct parts of a field group is to create one with the features you want and then export it to code, then use that as an example.

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

You must be logged in to reply to this topic.