• Resolved Yannick Lefebvre

    (@jackdewey)


    Hi, I am a plugin development and one of my plugins (https://en-ca.www.ads-software.com/plugins/bilingual-linker/) allowed users to add an item to their menu with the classic menu editor.

    With the FSE, I am starting to get some users asking me for the equivalent functionality with the new navigation block editor. I have made some blocks before, but these blocks do not appear in the list of blocks that can be added to navigation.

    What makes a block appear in the list of blocks that can be used in navigation in the FSE? Can anyone point me to a code sample perhaps?

    Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • I recently faced the same question. I found the solution here: https://github.com/WordPress/gutenberg/issues/31387 – according to this, you have to give register_block_type() the parameter “parent” and say that “core/navigation” is the parent block for this block.

    Example in PHP:

    register_block_type(
    				'path_to_custom_navigation_block/',
    				array(
    					'render_callback' => 'custom_block_callback_function',
    					'attributes' => array(
    						'preview' => array(
    							'type' => 'boolean',
    							'default' => false,
    						)
    					),
    					'parent' => array( 'core/navigation' ),
    				)
    			);
    Thread Starter Yannick Lefebvre

    (@jackdewey)

    Thank you so much! I was able to create navigation block elements using this and provide that to my users.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘FSE navigation block code template’ is closed to new replies.