• Resolved Carlos Silva

    (@kbzati)


    Thank you very much for this plugin it is excellent and has saved me a lot of time.

    I am testing with the new FSE editor and the Single Template with ACF.

    I have a checkbox ACF and I get the following message:
    This data type is not supported! Please contact the author for help.

    How can I display checkbox or select ACF with your plugin?

    Thank you in advance for your help

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Phi Phan

    (@mr2p)

    Hello Carlos @kbzati,

    I will add a code snippet for the checkbox field very soon.

    Thanks, Phi.

    Plugin Author Phi Phan

    (@mr2p)

    Hi @kbzati, I will support all choice field types in the next version. For now, here is the code snippet to support displaying checkbox fields.

    add_filter(
    	'meta_field_block_get_acf_field',
    	function ( $field_value, $post_id, $field ) {
    		$field_type = $field['type'] ?? '';
    
    		if ( 'checkbox' === $field_type ) {
    			$raw_value = $field['value'] ?? [];
    			if ( $raw_value ) {
    				if ( is_array( $raw_value ) ) {
    					$refine_value = array_filter(
    						array_map(
    							function ( $item ) {
    								$return_value = '';
    								if ( $item ) {
    									// Return format as both
    									if ( is_array( $item ) ) {
    										$return_value = $item['value'] ?? '' ? $item['value'] : '';
    									} else {
    										$return_value = $item;
    									}
    								}
    
    								return $return_value;
    							},
    							$raw_value
    						)
    					);
    
    					if ( $refine_value ) {
    						$field_value = implode( ', ', $refine_value );
    					}
    				}
    			} else {
    				$field_value = '';
    			}
    		}
    
    		return $field_value;
    	},
    	10,
    	3
    );

    By editing the above snippet, you can also display other choice fields.

    Plugin Author Phi Phan

    (@mr2p)

    Hi @kbzati, I’ve released a new version for all choice field types: true/false, checkbox, select, radio, button group. Please get the latest version 1.1.3, you don’t have to use the above code snippet.

    Thank you very much for your feedback, if you have time and you don’t mind, please help this plugin by giving it a rating as well.

    Thanks, Phi.

    Thread Starter Carlos Silva

    (@kbzati)

    Hi @mr2p , I’ve just tested and works great. Thanks for your excellent plugin.

    Of course, I will rate this plugin with 5 stars. Thanks for sharing it.

    Do you plan to show repeater fields in a next update?

    Best regards,

    Carlos Silva

    Plugin Author Phi Phan

    (@mr2p)

    Hi @kbzati, I’m glad it works for you.

    I’ve been developing a Pro version that supports the Group field, repeater field, and flexible content field. The repeater field can be rendered as a responsive grid, carousel, or vertical stack layout. The flexible content field can be used as a page builder. The relationship and post object fields also can be rendered as a custom Query Loop block that also supports responsive grid layout, carousel layout, etc.

    The advanced version will be released in upcoming weeks.

    Thanks, Phi.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How can I display ACF checkbox fields?’ is closed to new replies.