两种帖子类型的高级自定义字段 - wordpress

问题描述 投票:0回答:1

我需要在两个页面中添加带有php的字段(在高级自定义字段插件wordpress

这是我的尝试:

acf_add_local_field_group(array (
    'key' => 'songs_options',
    'title'      => 'songs options',
    'fields' => array (
        array (
            'key' => 'field_1',
            'label' => 'test title',
            'name' => 'test_field',
            'type' => 'text',
        ),
    ),
    'location' => array (
        array (
            array (
                'param' => 'post_type',
                'operator' => 'IN', 
                'value' => array( 'songs', 'videos'),  // i need a code like this line
            ),
        )
    ),
));
php wordpress advanced-custom-fields
1个回答
2
投票

您应该对位置使用

==
运算符,并将每个位置添加为“位置”下的不同数组:

register_field_group(array (
    'key'    => 'songs_options',
    'title'  => 'songs options',
    'fields' => array (
        array (
            'key'   => 'field_1',
            'label' => 'test title',
            'name'  => 'test_field',
            'type'  => 'text',
        ),
    ),
    'location' => array (
        array (
            array (
                'param'    => 'post_type',
                'operator' => '==', 
                'value'    => 'songs',
            ),
        ),
        array (
            array (
                'param'    => 'post_type',
                'operator' => '==', 
                'value'    => 'videos',
            ),
        ),
    ),
));
© www.soinside.com 2019 - 2024. All rights reserved.