How to remove a Collection from Genesis Blocks


The library of Collections (of block patterns) in Genesis Blocks is growing. The designs produced by the same team that crafted the StudioPress themes are incredible and are proving to be super useful to plenty in the Genesis community.

However, you may not want all of these Collections available to content creators on your site. Or none of them even. You might have designed and built a custom on-brand Collection and having the rest of the library there is actually distracting.

So this snippet of code below, which you can add to your theme (child theme) or in a plugin, is how you can remove a Collection you don’t need. This one targets the Agency collection, but you can target whichever Collection you need via the $collection_slug variable.

function gb_agency_collection_remover() {

	// Change this to the slug of the collection you wish to remove
	$collection_slug = 'agency';

	// Get all of the registered patterns (sections and layouts).
	$patterns  = genesis_blocks_get_layouts() + genesis_blocks_get_sections();

	// Loop through each section.
	foreach ( $patterns as $layout_data ) {
		if ( isset( $layout_data['collection'] ) ) {
			if ( $collection_slug === $layout_data['collection']['slug'] ) {
				// Unregister this layout component if it is in the collection we don't want.
				$result = genesis_blocks_unregister_layout_component( $layout_data['type'], $layout_data['key'] );
add_action( 'plugins_loaded', 'gb_agency_collection_remover', 13 );


Designed by Agency Hut

Leave a Reply