Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

First custom block added to a post renders fields in sidebar instead of main well, before save/refresh

Aperta
#1,020 3 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
php, wordpress
Ambito
frontend, web-dev

Direzione di ricerca

Inizia dalla registrazione di row_init_block_conveyor e dalla sua impostazione mode => 'auto', quindi riproduci il caso del primo blocco nell’editor di WordPress usando il gruppo di campi ACF fornito. Il lavoro è completato quando i campi di ogni blocco ACF personalizzato vengono visualizzati inline nell’area di modifica al primo inserimento.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug
When inserting a custom ACF block into a post that contains no other custom ACF blocks, the block's fields render in the right-rail Block panel instead of inline in the editor canvas. All subsequently added blocks (of any ACF block type) render correctly in the canvas. The affected block also renders correctly after refreshing the page.

To reproduce
Open any post that contains no custom ACF blocks
Insert a custom ACF block (that was registered with 'mode' => 'auto')
Observe that block fields render in the right-rail Block panel, not in the editor canvas
Insert any second custom ACF block
Observe that the second block's fields render correctly in the editor canvas
Refresh the page — the first block now also renders correctly

The behavior is the same across block types: whichever block is inserted first exhibits the bug, regardless of type.

Expected behavior
All custom ACF block fields render in the editor canvas, consistently, on first insertion.

Screenshots or Video

first custom block in post:
Image

same block added second:
Image

Code

<?php
/**
 *  Conveyor Gallery Block
 */

add_action('acf/init', 'row_init_block_conveyor');

function row_init_block_conveyor() {
	if( function_exists('acf_register_block_type') ) {
		acf_register_block_type(array(
			'name'            => 'conveyor-gallery',
			'title'           => __('Conveyor Gallery'),
			'description'     => __('Insert scrolling text / sticky image gallery.'),
			'render_template' => 'admin/blocks/templates/conveyor-gallery-tpl.php',
			'category'        => 'media',
			'icon'            => 'id',
			'keywords'        => array('conveyor', 'gallery', 'sift', 'sticky', 'scrolly'),
			'supports'        => array(
				'color' => array(
					'text' => false,
					'background' => true,
					'gradients' => false
				), 
			),
			'mode' => 'auto'
		));
	}
}

if( function_exists('acf_add_local_field_group') ):

	$text_size_field = array(
		'key' => 'field_block_dd_1100',
		'label' => 'Text Size',
		'name' => 'text_size',
		'type' => 'button_group',
		'instructions' => '',
		'required' => 0,
		'conditional_logic' => 0,
		'choices' => array(
			'medium' => 'Medium',
			'large'  => 'Large',
			'xlarge' => 'X-Large',
		),
		'allow_null' => 0,
		'default_value' => 'medium',
		'layout' => 'horizontal',
		'return_format' => 'value'
	);

	$text_align_field = array(
		'key' => 'field_block_dd_1400',
		'label' => 'Text Alignment',
		'name' => 'text_alignment',
		'type' => 'button_group',
		'instructions' => '',
		'required' => 0,
		'conditional_logic' => 0,
		'choices' => array(
			'left'   => 'Left',
			'right'  => 'Right',
			'center' => 'Center',
		),
		'allow_null' => 0,
		'default_value' => 'center',
		'layout' => 'horizontal',
		'return_format' => 'value'
	);

	$text_background_field = array(
		'key' => 'field_block_dd_1200',
		'label' => 'Text Background',
		'name' => 'text_background',
		'type' => 'true_false',
		'instructions' => '',
		'required' => 0,
		'conditional_logic' => 0,
		'message' => '',
		'default_value' => 0,
		'ui' => 1,
		'ui_on_text' => 'On',
		'ui_off_text' => 'Off'
	);

	$background_color_field = array(
		'key' => 'field_block_dd_1300',
		'label' => 'Background Color',
		'name' => 'screen_background',
		'type' => 'button_group',
		'instructions' => '',
		'required' => 0,
		'conditional_logic' => 0,
		'choices' => array(
			'black' => 'Black',
			'grey' => 'Grey',
			'body' => 'Body',
		),
		'allow_null' => 0,
		'default_value' => '',
		'layout' => 'horizontal',
		'return_format' => 'value'
	);

	$media_type_field = array(
		'key' => 'field_block_dd_2100',
		'label' => 'Media',
		'name' => 'media',
		'type' => 'button_group',
		'instructions' => '',
		'required' => 0,
		'conditional_logic' => 0,
		'choices' => array(
			'image' => 'Image',
			'video' => 'Video',
		),
		'allow_null' => 0,
		'default_value' => 'image',
		'layout' => 'horizontal',
		'return_format' => 'value'
	);

	$img_field = array(
		'key' => 'field_block_dd_2200',
		'label' => 'Image',
		'name' => 'image',
		'type' => 'image',
		'instructions' => '',
		'required' => 1,
		'conditional_logic' => array(
			array(
				array(
					'field' => 'field_block_dd_2100',
					'operator' => '==',
					'value' => 'image',
				),
			),
		),
		'return_format' => 'array',
		'preview_size' => 'thumbnail',
		'library' => 'all'
	);

	$mobile_img_field = array(
		'key' => 'field_block_dd_2300',
		'label' => 'Mobile Image',
		'name' => 'mobile_image',
		'type' => 'image',
		'instructions' => '',
		'required' => 0,
		'conditional_logic' => array(
			array(
				array(
					'field' => 'field_block_dd_2100',
					'operator' => '==',
					'value' => 'image',
				),
			),
		),
		'return_format' => 'array',
		'preview_size' => 'thumbnail',
		'library' => 'all'
	);

	$video_type_field = array(
		'key' => 'field_block_dd_2400',
		'label' => 'Video Source',
		'name' => 'video_source',
		'type' => 'button_group',
		'instructions' => '',
		'required' => 0,
		'conditional_logic' => array(
			array(
				array(
					'field' => 'field_block_dd_2100',
					'operator' => '==',
					'value' => 'video',
				),
			),
		),
		'choices' => array(
			'vimeo'     => 'Vimeo',
			'wordpress' => 'WordPress',
		),
		'allow_null' => 0,
		'default_value' => 'vimeo',
		'layout' => 'horizontal',
		'return_format' => 'value',
	);

	$landscape_vimeo_field = array(
		'key' => 'field_block_dd_2500',
		'label' => 'Landscape Video',
		'name' => 'landscape_video_vimeo',
		'type' => 'url',
		'instructions' => '',
		'required' => 0,
		'conditional_logic' => array(
			array(
			array(
				'field' => 'field_block_dd_2100',
				'operator' => '==',
				'value' => 'video',
			),
			array(
				'field' => 'field_block_dd_2400',
				'operator' => '==',
				'value' => 'vimeo',
			),
			),
		),
		'default_value' => '',
		'placeholder' => ''
	);

	$landscape_vimeo_ratio_field = array(
		'key' => 'field_block_dd_2550',
		'label' => 'Aspect Ratio',
		'name' => 'landscape_vimeo_aspect_ratio',
		'type' => 'select',
		'instructions' => '',
		'required' => 1,
		'conditional_logic' => 0,
		'wrapper' => array(
			'width' => '',
			'class' => '',
			'id' => '',
		),
		'choices' => array(
			'16x9' => '16:9',
			'4x3' => '4:3',
			'1x1' => '1:1',
		),
		'conditional_logic' => array(
			array(
			array(
				'field' => 'field_block_dd_2100',
				'operator' => '==',
				'value' => 'video',
			),
			array(
				'field' => 'field_block_dd_2400',
				'operator' => '==',
				'value' => 'vimeo',
			),
			array(
				'field' => 'field_block_dd_2500',
				'operator' => '!=',
				'value' => '',
			),
			),
		),
		'default_value' => false,
		'allow_null' => 0,
		'multiple' => 0,
		'ui' => 0,
		'return_format' => 'value',
		'ajax' => 0,
		'placeholder' => ''
	);

	$portrait_vimeo_field = array(
		'key' => 'field_block_dd_2600',
		'label' => 'Portrait Video',
		'name' => 'portrait_video_vimeo',
		'type' => 'url',
		'instructions' => '',
		'required' => 0,
		'conditional_logic' => array(
			array(
				array(
					'field' => 'field_block_dd_2100',
					'operator' => '==',
					'value' => 'video',
				),
				array(
					'field' => 'field_block_dd_2400',
					'operator' => '==',
					'value' => 'vimeo',
				),
			),
		),
		'default_value' => '',
		'placeholder' => ''
	);

	$portrait_vimeo_ratio_field = array(
		'key' => 'field_block_dd_2650',
		'label' => 'Aspect Ratio',
		'name' => 'portrait_vimeo_aspect_ratio',
		'type' => 'select',
		'instructions' => '',
		'required' => 1,
		'conditional_logic' => 0,
		'wrapper' => array(
			'width' => '',
			'class' => '',
			'id' => '',
		),
		'choices' => array(
			'9x16' => '9:16',
			'6x13' => '6:13',
			'4x5' => '4:5'
		),
		'conditional_logic' => array(
			array(
				array(
					'field' => 'field_block_dd_2100',
					'operator' => '==',
					'value' => 'video',
				),
				array(
					'field' => 'field_block_dd_2400',
					'operator' => '==',
					'value' => 'vimeo',
				),
				array(
					'field' => 'field_block_dd_2600',
					'operator' => '!=',
					'value' => '',
				),
			),
		),
		'default_value' => false,
		'allow_null' => 0,
		'multiple' => 0,
		'ui' => 0,
		'return_format' => 'value',
		'ajax' => 0,
		'placeholder' => ''
	);

	$landscape_wp_field = array(
		'key' => 'field_block_dd_2700',
		'label' => 'Landscape Video',
		'name' => 'landscape_video_wordpress',
		'type' => 'file',
		'instructions' => '',
		'required' => 0,
		'conditional_logic' => array(
			array(
				array(
					'field' => 'field_block_dd_2100',
					'operator' => '==',
					'value' => 'video',
				),
				array(
					'field' => 'field_block_dd_2400',
					'operator' => '==',
					'value' => 'wordpress',
				),
			),
		),
		'return_format' => 'array',
		'library' => 'all',
		'min_size' => '',
		'max_size' => '',
		'mime_types' => 'mp4'
	);

	$portrait_wp_field = array(
		'key'   => 'field_block_dd_2800',
		'label' => 'Portrait Video',
		'name'  => 'portrait_video_wordpress',
		'type'  => 'file',
		'instructions' => '',
		'required' => 0,
		'conditional_logic' => array(
			array(
				array(
					'field' => 'field_block_dd_2100',
					'operator' => '==',
					'value' => 'video',
				),
				array(
					'field' => 'field_block_dd_2400',
					'operator' => '==',
					'value' => 'wordpress',
				),
			),
		),
		'return_format' => 'array',
		'library' => 'all',
		'min_size' => '',
		'max_size' => '',
		'mime_types' => 'mp4'
	);

	$text_field = array(
		'key' => 'field_block_dd_2900',
		'label' => 'Text',
		'name' => 'text',
		'type' => 'textarea',
		'instructions' => '',
		'required' => 1,
		'conditional_logic' => 0,
		'maxlength' => ''
	);

	acf_add_local_field_group(array(
		'key' => 'group_100e1000e1000',
		'title' => 'Conveyor Gallery',
		'fields' => array(
			array(
				'key' => 'field_block_dd_1000',
				'label' => 'Appearance',
				'name' => 'appearance',
				'type' => 'group',
				'instructions' => '',
				'required' => 0,
				'conditional_logic' => 0,
				'wrapper' => array(
					'width' => '',
					'class' => '',
					'id' => '',
				),
				'layout' => 'row',
				'sub_fields' => array(
					$text_size_field,
					$text_align_field,
					$text_background_field,
					$background_color_field,
				),
			),
			array(
				'key' => 'field_block_dd_2000',
				'label' => 'Screens',
				'name' => 'screens',
				'type' => 'repeater',
				'instructions' => '',
				'required' => 0,
				'conditional_logic' => 0,
				'wrapper' => array(
					'width' => '',
					'class' => '',
					'id' => '',
				),
				'collapsed' => 'field_block_dd_2900',
				'min' => 2,
				'max' => 0,
				'layout' => 'row',
				'button_label' => 'Add Screen',
				'sub_fields' => array(
					$media_type_field,
					$img_field,
					$mobile_img_field,
					$video_type_field,
					$landscape_vimeo_field,
					$landscape_vimeo_ratio_field,
					$portrait_vimeo_field,
					$portrait_vimeo_ratio_field,
					$landscape_wp_field,
					$portrait_wp_field,
					$text_field,
				),
			),
		),
		'location' => array(
			array(
				array(
					'param' => 'block',
					'operator' => '==',
					'value' => 'acf/conveyor-gallery',
				),
			),
		),
		'menu_order' => 0,
		'position' => 'normal',
		'style' => 'default',
		'label_placement' => 'top',
		'instruction_placement' => 'label',
		'hide_on_screen' => ''
	));

endif;

Version Information

WordPress Version: 7.0.1
PHP Version: 8.3.17
ACF Version: ACF PRO 6.8.6
Browser: Google Chrome v149

Lingua principale
PHP
Stelle
948
Fork
198
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AdvancedCustomFields/acf

Tutte le issue di AdvancedCustomFields/acf

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.