Tag name to container

Hi,

I would like to add tags to container, other that the ones by default. For example, tag like “Blockquote” or “li”.

I know that the feature is under consideration. But is it coming in near future or not ? What are the solutions for now?

Reference: Add more tag names for container · Issue #750 · tomusborne/generateblocks · GitHub

Hi @Remiliko,

You can use a couple of filters for that.

Here’s a PHP snippet you can try:

	add_filter('generateblocks_container_allowed_tagnames', function($allowed, $attributes, $block){
	if ( !is_admin() && ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'cu-container' ) !== false ) {
		$allowed[] ="li";
	}
	return $allowed;
}, 10, 3);
add_filter('generateblocks_container_tagname', function($tagname, $attributes, $block){
	if ( !is_admin() && ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'cu-container' ) !== false ) {
		return 'li';
	}
	return $tagname;
}, 10, 3);

Replace li in the code with your preferred tagname.

Then, add cu-container to the classist of the Container Block. Adding Custom Classes: Add Additional CSS Classes to Blocks – WordPress.com Support