HomeHow To'sHow to Disable All Patterns Using Pattern Wrangler

How to Disable All Patterns Using Pattern Wrangler

Empty Patterns Library Using Pattern Wrangler to Disable Patterns
Empty Patterns Library Using Pattern Wrangler to Hide Patterns

While you may be a fan of the block editor, you may not be a fan of block patterns. With Pattern Wrangler, you can easily hide all patterns. In this “How To,” I’ll show you how.

Pattern Wrangler – Manage Block Patterns and Pattern Categories

By: Ronald Huereca
4 Ratings
Last Updated: 19 hours ago
Curate and manage your block patterns, registered patterns, synced patterns, and pattern categories efficiently with Pattern Wrangler.

How to disable patterns with a code snippet

If a plugin is not our thing, here’s a snippet on how to disable block patterns altogether.

PHP
<?php
/**
 * Disable local patterns.
 */
add_filter(
	'rest_wp_block_query',
	function ( $query_args ) {
		$query_args['post__in'] = array( -1 ); // -1 so no patterns are returned.
		return $query_args;
	},
	10,
	1
);

/**
 * Disable remote patterns.
 */
add_filter( 'should_load_remote_block_patterns', '__return_false' );

/**
 * Deregister the rest of the patterns.
 */
add_action(
	'init',
	function () {
		// Retrieve all patterns.
		$patterns     = \WP_Block_Patterns_Registry::get_instance();
		$all_patterns = $patterns->get_all_registered();

		// Loop through all patterns and deregister them.
		foreach ( $all_patterns as $index => $pattern ) {
			unregister_block_pattern( $pattern['name'] );
		}
	},
	2000
);

Paste this snippet into a site-specific plugin, code snippet plugin, or MU-Plugin.

Disabling patterns with the free Pattern Wrangler plugin

For a no-code and Multisite-friendly solution, install the free Pattern Wrangler plugin.

Navigate to its settings, which you can find under Patterns->Settings.

Go to Patterns->Settings to find the Pattern Wrangler Settings

Find “Hide all Patterns”, toggle it to on, and save the settings.

Enable the Hide All Patterns Toggle

Alternatively, hide the Patterns menu item (recommended if hiding patterns) under Appearance.

Hide Patterns Menu Item is an Optional Selection

Your patterns should now be hidden.

Patterns View – No Results Found

Conclusion

In this short “How To,” I demonstrated, via code and the WordPress plugin Pattern Wrangler, how to disable all patterns.

Ask a Question or Leave Feedback

Your email address will not be published. Required fields are marked *