Support

Account

Home Forums General Issues Get data type of field in WP_Query Reply To: Get data type of field in WP_Query

  • Hello,
    Use ‘get_fields()’ and ‘get_field_object()’.

    
    $loop = new WP_Query( $args );  
    $posts = $loop->get_posts(); 
    foreach ( $posts as $post ) {
    	$acf_fields = get_fields();
    	//var_dump($acf_fields);
    	foreach ( $acf_fields as $key => $value ) {
    		$field_object = get_field_object( $key );
    		echo "<pre>";
    		var_dump( $field_object );
    		echo "</pre>";
    		echo "This Field Type is <strong>" . $field_object['type'] . "</strong>\n";
    	}
    }
    

    http://www.advancedcustomfields.com/resources/functions/get_fields/
    http://www.advancedcustomfields.com/resources/functions/get_field_object/

    Please check the return value use the ‘var_dump()’.
    http://www.advancedcustomfields.com/resources/how-to/debug/