Support

Account

Home Forums ACF PRO Adding locations to a field group Reply To: Adding locations to a field group

  • ok, I’m almost there 🙂

    I modified the code like this :

    
    add_filter('acf/get_field_group', 'my_modify_field_group_function');
    function my_modify_field_group_function($group) {
    
    	if ($group['key'] != 'group_58c6bfd3a0239') {   // note: I replaced $field with $group
    	// not our field group
    	return;
    	
    	} else {
    
    		// add an OR rule to existing location rules for a specific field group
    		$group['location'] = array(
    			array (
    				array (
    					'param' => 'post_type',
    					'operator' => '==',
    					'value' => 'portfolio',
    				),
    			),
    			array (
    				array (
    					'param' => 'post_type',
    					'operator' => '==',
    					'value' => 'team',
    				),
    			),
    			array (
    				array (
    					'param' => 'post_type',
    					'operator' => '==',
    					'value' => 'page',
    				),
    			),
    			array (
    				array (
    					'param' => 'post_type',
    					'operator' => '==',
    					'value' => 'post',
    				),
    			)
    		);
    		return $group;
    
    		
    	}
    	
    }
    

    Now it’s working, I have the field group of my plugin available for portfolio and team. But the problem is that I cannot manually create other field groups… They appear inactive, and the fields seems not saved!

    the the screenshots without the filter, and with the filter