{"id":46372,"date":"2025-03-23T09:00:19","date_gmt":"2025-03-23T09:00:19","guid":{"rendered":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/?p=46372"},"modified":"2026-10-10T20:02:37","modified_gmt":"2026-10-10T20:02:37","slug":"disable-default-block-theme-patterns","status":"publish","type":"post","link":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/disable-default-block-theme-patterns\/","title":{"rendered":"Disable Default Block Patterns in WordPress"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">To disable the default block patterns in WordPress, so the inserter only shows the patterns of your theme and your own, remove the <code>core-block-patterns<\/code> theme feature and stop WordPress from loading patterns from WordPress.org.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That leaves the Patterns tab of a custom or blank theme clean for clients: no query loop and navigation overlay patterns from core, and no featured patterns pulled from the Pattern Directory.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The snippet<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">&lt;?php\n\/**\n * Disable the default (core) block patterns and the patterns WordPress\n * loads from the WordPress.org Pattern Directory.\n *\/\nadd_action( 'after_setup_theme', 'dpc_disable_core_block_patterns' );\n\nfunction dpc_disable_core_block_patterns() {\n\t\/\/ Core registers its patterns on init only while the theme supports this feature.\n\tremove_theme_support( 'core-block-patterns' );\n}\n\n\/\/ No patterns fetched from api.wordpress.org (featured, Directory and theme.json \"patterns\").\nadd_filter( 'should_load_remote_block_patterns', '__return_false' );<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">How it works<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>WordPress turns the <code>core-block-patterns<\/code> feature on for every theme, and on <code>init<\/code> it registers its own <code>core\/...<\/code> patterns only while that feature is on. The snippet removes the feature on <code>after_setup_theme<\/code>, which runs before <code>init<\/code>.<\/li>\n\n\n<li><code>should_load_remote_block_patterns<\/code> controls every pattern WordPress fetches from api.wordpress.org: the core keyword patterns, the featured patterns and the Directory patterns a theme lists under <code>patterns<\/code> in <code>theme.json<\/code>. Returning <code>false<\/code> turns all of them off and saves the editor those HTTP requests.<\/li>\n\n\n<li>Patterns from your theme&#8217;s <code>patterns\/<\/code> folder and patterns registered with <code>register_block_pattern()<\/code> are not touched.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The older version of this post removed the theme support on <code>init<\/code>, after core had already registered its patterns, so only the remote patterns disappeared.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Add it with Scripts Organizer<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In <a href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/dplugins.com\/downloads\/scripts-organizer\/\">Scripts Organizer<\/a> go to <strong>Code Blocks \u2192 Add New<\/strong> and give the block a name. Set <strong>Trigger location<\/strong> to <strong>Everywhere<\/strong>, tick <strong>PHP<\/strong> under <strong>Script location<\/strong>, paste the code into the PHP editor and publish. Leave <strong>Action\/Hook<\/strong> empty. Patterns are registered on every request type, including the REST API calls the editor makes, so the code needs to run everywhere, not only in wp-admin.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The same code also works unchanged in a small plugin or an mu-plugin.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Customise it<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Keep the core patterns and only stop the remote ones: delete the <code>add_action()<\/code> line and its function.<\/li>\n\n\n<li>Keep the remote patterns: delete the <code>add_filter()<\/code> line.<\/li>\n\n\n<li>Remove a single pattern instead: call <code>unregister_block_pattern( 'core\/query-grid-posts' )<\/code> on <code>init<\/code> with a priority above 10.<\/li>\n\n\n<li>Hide pattern categories you don&#8217;t use with <code>unregister_block_pattern_category()<\/code> on <code>init<\/code>.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Gotchas<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Synced patterns and patterns saved by users in the Site Editor are content, not registered patterns, so they stay.<\/li>\n\n\n<li>Some plugins register their own patterns; remove those with <code>unregister_block_pattern()<\/code> and the plugin&#8217;s pattern name.<\/li>\n\n\n<li>A lighter editor for single post types is a different job; see <a href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/disable-gutenberg-for-specific-post-types\/\">Disable Gutenberg for Specific Post Types in WordPress<\/a>.<\/li>\n\n<\/ul>\n\n","protected":false},"excerpt":{"rendered":"<p>Disable the default WordPress core block patterns and the Pattern Directory patterns so the inserter only shows your theme&#8217;s own patterns.<\/p>\n","protected":false},"author":1,"featured_media":46764,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Disable Default Block Patterns in WordPress - Code DPlugins","description":"Disable the default WordPress core block patterns and the Pattern Directory patterns so the inserter only shows your theme's own patterns."},"_slim_seo_primary_term_category":0,"_slim_seo_primary_term_post_tag":0,"footnotes":""},"categories":[90],"tags":[],"dpc_library":[204],"class_list":["post-46372","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-gutenberg"],"_links":{"self":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/46372","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/comments?post=46372"}],"version-history":[{"count":1,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/46372\/revisions"}],"predecessor-version":[{"id":46763,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/46372\/revisions\/46763"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/media\/46764"}],"wp:attachment":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/media?parent=46372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/categories?post=46372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/tags?post=46372"},{"taxonomy":"dpc_library","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/dpc_library?post=46372"}],"curies":[{"name":"wp","href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/api.w.org\/{rel}","templated":true}]}}