get_dynamic_block_names()

Returns an array of the names of all registered dynamic block types.


Description Description


Return Return

(array) Array of dynamic block names.


Top ↑

Source Source

File: wp-includes/blocks.php

function get_dynamic_block_names() {
	$dynamic_block_names = array();

	$block_types = WP_Block_Type_Registry::get_instance()->get_all_registered();
	foreach ( $block_types as $block_type ) {
		if ( $block_type->is_dynamic() ) {
			$dynamic_block_names[] = $block_type->name;
		}
	}

	return $dynamic_block_names;
}

Top ↑

Changelog Changelog

Changelog
Version Description
5.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Nilambar Sharma
    // Fetch block names.
    $block_names = get_dynamic_block_names();
    
    // Output.
    Array
    (
        [0] => core/block
        [1] => core/latest-comments
        [2] => core/archives
        [3] => core/calendar
        [4] => core/categories
        [5] => core/latest-posts
        [6] => core/rss
        [7] => core/search
        [8] => core/shortcode
        [9] => core/tag-cloud
    )

You must log in before being able to contribute a note or feedback.