Support

Account

Home Forums General Issues Registering fields via PHP: Location rules for post category?

Unread

Registering fields via PHP: Location rules for post category?

  • I’m trying to register a field group via PHP, but I’m stuck with setting the location rules. I’ve couldn’t find this in the documentation.

    Basically, I want to set this location rule via PHP: ACF Location rule

    This is my code thus far, which is not working:

    if( function_exists('acf_add_local_field_group') ):
    
    	acf_add_local_field_group(array(
    		'key' => 'group_' . uniqid(),
    		'title' => 'Product Information Tabs',
    		'fields' => array (
    			array (
    				'key' => 'field_tab_' . uniqid(),
    				'label' => 'Tab title',
    				'name' => 'tab_test',
    				'type' => 'wysiwyg',
    
    			)
    		),
    		'location' => array (
    			array (
    				array (
    					'param' => 'post_taxonomy',
    					'operator' => '==',
    					'value' => 'product_cat(cat-food)' ,
    				),
    			),
    		),
    	));
    	
    	endif;

    The category slug for the “Cat food” category is cat-food.

    What am I doing wrong?

Viewing 1 post (of 1 total)

The topic ‘Registering fields via PHP: Location rules for post category?’ is closed to new replies.