Support

Account

Home Forums General Issues Get a field object outside of the post context Reply To: Get a field object outside of the post context

  • yes that’s it.

    Because I have an option to sort by post type in my search form, i would like to be able to search for all post OR just certain post types.

    if possible i don’t want to make a wp query just to get the field options, i want to get the field options like on the export tools on acf admin page (i don’t care about all that, but it is just an example of sorting the field structure without a $post->ID) :

    if( function_exists(‘acf_add_local_field_group’) ):

    acf_add_local_field_group(array (
    	'key' => 'group_55ba39c6cc9d7',
    	'title' => 'Langues',
    	'fields' => array (
    		array (
    			'key' => 'field_55ba39cd8bb11',
    			'label' => 'Langue',
    			'name' => 'langue',
    			'type' => 'select',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'choices' => array (
    				'francais' => 'Fran├žais',
    				'anglais' => 'Anglais',
    				'espagnol' => 'Espagnol',
    				'allemand' => 'Allemand',
    				'portugais' => 'Portugais',
    				'russe' => 'Russe',
    				'arabe' => 'Arabe',
    				'chinois' => 'Chinois',
    				'hindi' => 'Hindi',
    				'japonais' => 'Japonais',
    				'autre' => 'Autre',
    			),
    			'default_value' => array (
    				'francais' => 'francais',
    			),
    			'allow_null' => 1,
    			'multiple' => 0,
    			'ui' => 0,
    			'ajax' => 0,
    			'placeholder' => '',
    			'disabled' => 0,
    			'readonly' => 0,
    		),
    	),
    	'location' => array (
    		array (
    			array (
    				'param' => 'post_type',
    				'operator' => '==',
    				'value' => 'document',
    			),
    		),
    	),
    	'menu_order' => 1,
    	'position' => 'acf_after_title',
    	'style' => 'default',
    	'label_placement' => 'top',
    	'instruction_placement' => 'label',
    	'hide_on_screen' => '',
    	'active' => 1,
    	'description' => '',
    ));
    
    endif;