Dynamic links

The dynamic links interface will appear on the block toolbar when using Element or Text blocks with the HTML tag name <a>:

Not to be confused with another “link” item on the toolbar that is used for adding a link to Rich Text (as in it will not add a link to the block’s root element, but will wrap some part of the text inside the block in an additional <a> element which is not valid HTML):


Some of the Dynamic links (E-mail, Phone, Facebook, Instagram) on the above example picture are static links from the Dynamic content option. The Front page, Blog, Permalink and Privacy policy links, how ever are registered via Dynamic links API provided by ska-blocks plugin.

Add a dynamic link

Additional dynamic links can be registered with the following code:

Custom dynamic linkPHP
add_action('ska_blocks_init', function() {

	ska_blocks()->get('dynamic-links')->register_dynamic_link([
		'slug' => 'link-slug',
		'label' => 'Link title',
		'callback' => function($link_attrs, $block) {
			return 'https://example.com';
		},
		'is_active' => function($link_attrs, $block) {
			return false;
		},
	]);
});

You should provide a slug, label and a callback to the register_dynamic_link function. is_active function is optional.

The arguments for the callback functions are as follows:

/**
 * @param array $link_attrs Array containing link attributes.
 * @param WP_Block $block Block instance.
 */

Once added your dynamic link should show up under Dynamic links when editing a link of Element or Text blocks.