4 Easy Steps to Remove Core WordPress Blocks

Learn how to remove core WordPress blocks and improve your theme’s design and functionality. Our guide provides detailed steps for unregistering unnecessary blocks.

While I try to support all major components in the theme builder, sometimes it makes sense to remove core WordPress block/components. Mainly because I’ve developed a custom tool that seems to be my main stop when dealing with design and performance requirements. Most of my themes include a ‘Content and Images’ block, similar to ‘Media and Text’ but with the theme’s grid layout.

Sometimes I save a “Call” book and make my own call. Use the php file in the theme that ensures the search block matches the design and functionality of the search function used elsewhere in the theme.

Table of Contents

  1. Why Remove Core Blocks
  2. Enqueue Block Editor Assets
  3. Unregister Block Type
  4. Unregister Blocks Everywhere

Why Remove Core WordPress Blocks

If you need more control over your theme’s design and functionality, removing important components can be helpful. Blocking products can provide a better experience and better match your theme’s unique features and aesthetics. For example, you can use the enqueue_block_editor_assets hook to load the text and style into the
editor.

  • Consistency: Custom blocks ensure consistent design across your site.
  • Functionality: Tailored blocks can offer additional or specific functionality that core blocks lack.
  • Performance: Removing unused core blocks can reduce bloat and improve performance.

Enqueue Block Editor Assets

My themes usually have an author. I create the js file that I use in block mode and save the block type. I also want custom fonts used internally so I can use them in the editing process as well. Here’s how to control author sources:

/**
 * Gutenberg scripts and styles
 *
 */
function be_gutenberg_scripts() {
    wp_enqueue_style( 'theme-fonts', be_theme_fonts_url() );
    wp_enqueue_script( 'theme-editor', get_template_directory_uri() . '/assets/js/editor.js', array( 'wp-blocks', 'wp-dom' ), filemtime( get_template_directory() . '/assets/js/editor.js' ), true );
}
add_action( 'enqueue_block_editor_assets', 'be_gutenberg_scripts' );
/**
 * Theme Fonts URL
 *
 */
function be_theme_fonts_url() {
    return 'https://fonts.googleapis.com/css2?family=Roboto+Slab&display=swap';
}

This code uploads your custom fonts and typefaces to the author block so you can personalize and manage the environment.

Unregister Block Type

Now that you have created an editor. You can place the js file into the
block editor and use wp. Stop UNRegisterBlockType To unregister the block type. Here is an example of how to register basic components:

jsCopy codewp.domReady( () => {
    wp.blocks.unregisterBlockType( 'core/media-text' );
    wp.blocks.unregisterBlockType( 'core/search' );
} );

This JavaScript component needs to be added to your editor. file. It ensures that the specified restrictions are not written and cannot be found by editing the editor.

Unregister Blocks Everywhere

The above code only saves the “Edit Post” block. If you are trying to remove restrictions on the Widgets screen, Full Site Editor, or Templates, you will need to change the settings.

You can extend the above process by ensuring that the unsubscribe process applies to all relevant areas. For a complete guide on how to unblock WordPress from any domain, check out this keyword:

Further Reading

For a comprehensive guide on unregistering WordPress blocks from all areas, refer to wordpress: How to Unregister WordPress Blocks (from everywhere!).

How to Unblock WordPress (Anywhere!). For more information, check out this article by Jason Lemahieu: Register a WordPress blog (fromplaces!) By following these steps, you can effectively manage the content available in your WordPress theme and ensure that your products deliver an efficient and effective experience. for your users.

Leave a Reply

noomaan_wordpress_developer-favicon-865f

Noman Ali

Noman Ali is web developer at Dev House, a custom software development agency focusing on high performance sites for web applications.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Other articles in this series

How to Seamlessly Add Facebook Comments in WordPress

Learn how to add Facebook comments in WordPress website to boost social engagement and simplify the commenting experience for your visitors. Step-by-step guide included.…

How to add Gutenberg Shortcodes in WordPress: A Comprehensive Guide

Unlock the power of Gutenberg shortcodes in WordPress to create dynamic, interactive, and SEO-friendly content. Learn how to use, customize, and optimize shortcodes for…

Learn Gutenberg Theme Development

Learn how to master Gutenberg theme development for WordPress with our comprehensive guide. Discover essential techniques, best practices, and advanced tips to create visually…

4 Easy Steps to Remove Core WordPress Blocks

Learn how to remove core WordPress blocks and improve your theme's design and functionality. Our guide provides detailed steps for unregistering unnecessary blocks.

Recommended Freeelancing Services