When building an adapted theme or working with an underlying theme, you may need to remove or hide certain styling functions, whether it is a single core block or a full variation in the theme style.
This is not just about preference. It often offers practical benefits, such as improved performance, more consistent design and a simpler user interface.
The approaches that have been followed to achieve these goals vary and are probably dependent on your needs and your skills. For the examples in this article we work with a child theme of twenty twenty-five (TT5), a modern WordPress block theme.
Not -register depends on how it is registered
For our purposes, when we refer to the non -registration of a block or theme style variation, we distinguish ourselves between complete and partial removal and whether the variation is completely removed or only hidden from the interface. The distinction is important.
Insight into how to register a block starts with knowing how it is registered. Core blocks registered with JavaScript, for example, are the best not registered in that language. On the other hand, variations in theme -style are registered with PHP and so a different approach can be in order.
Not registering custom blocks falls outside the cutlery of this article and your approach depends on how those blocks were originally registered.
What is a style variation?
WordPress makes a distinction between block styles and variations in theme style. Block styles are visual alternatives for a specific block, such as the “fill” or “circumference” styles of a button block. Block style variations are registered in the core, theme.json” block.json (or in a plug -in).
Variations in theme -Style, on the other hand, are complete visual alternatives that contain colors, typography and layouts that are defined in a unique theme.json file. They enable users to switch between different looks (skins) for a site without changing the theme. TT5 comes with eight style variations in addition to the standard style.
Take your first step: survey your scripts
Because we work with a child theme, you must ensure that you have to come up with your scripts properly.
With this setup you go on your way, including our habit to use us unregister-blocks.js file.
// Enqueue Parent and Child Styles
add_action('wp_enqueue_scripts', function () {
wp_enqueue_style(
'parent-style',
get_template_directory_uri() . '/style.css'
);
wp_enqueue_style(
'child-style',
get_stylesheet_uri(),
['parent-style'],
wp_get_theme()->get('Version')
);
});
// Enqueue styles in the WordPress admin
add_action('admin_enqueue_scripts', function () {
wp_enqueue_style(
'child-admin-style',
get_stylesheet_uri(),
[],
wp_get_theme()->get('Version')
);
});
// Enqueue JavaScript for block editor
add_action('enqueue_block_editor_assets', function () {
wp_enqueue_script(
'unregister-core-blocks',
get_stylesheet_directory_uri() . '/js/unregister-blocks.js',
['wp-blocks', 'wp-dom-ready', 'wp-edit-post'],
null,
true
);
});As you can see, we have a JavaScript file on js/unregister-blocks.jsIncluding all our scripts for this article.
Do not use get_template_directory_uri() For the JavaScript file, because this indicates the parent theme.
Timing is everything
Knowing when a hook is crucial when working with PHP in WordPress. You should be familiar with the basic loading series, which starts in wp-settings.php:
- Constant
- Sphere
- Core components
- Loadplugs -ins
- Load the theme
Finding the right point at which an adapted function must be performed is one of the most difficult and frustrating parts of WordPress development.
Not registering a core block style
Let’s look at a situation where you want to remove the style of a core block. In this case we want to remove the circumference style for the button block.
Because the filling and sketch button styles are registered in TT5s theme.json File, we use JavaScript to handle the process.
wp.domReady(() => {
if (wp.blocks && wp.blocks.unregisterBlockStyle) {
wp.blocks.unregisterBlockStyle('core/button', 'outline');
}
});The result is the removal of the circumference style in the toolbar and sidebar.
Do not register a core block
Suppose you want to remove all block styles for a block. A more rational approach is to register the block (or blocks) instead. This streamlines the inserturer by removing block (s) that you do not want users to use and improve the performance.
The quote block is removed here.
wp.domReady(() => {
wp.blocks.unregisterBlockType('core/quote');
});What happens if the script is performed after the quotation block has already been used? WordPress shows a message “This block is no longer available” in the editor, but the content still makes at the front. Users can manually edit or convert the RAW HTML display to which the block falls back.

You can go to HTML like-IS or convert to maintain the content and styling.
What about not registering more than one block? In this example, we switch off the quote and head blocks by carrying out a FOREAX loop to offer a very efficient way to do this.
wp.domReady(() => {
const blocksToRemove = [
'core/quote',
'core/heading',
];
blocksToRemove.forEach((blockName) => {
if (wp.blocks.getBlockType(blockName)) {
wp.blocks.unregisterBlockType(blockName);
}
});
});This script makes it easy to remove other blocks if necessary.

Do not register a variation of a theme style
The great thing about style variations in block themes is that they do not have to be registered, as you may have done with other WordPress extensions in the past.
Instead, they are automatically recognized by a core by simply installing a correctly prepared theme.json File in the root of the underlying theme or /styles Directory.
It is easy to assume that you need a function to register variations in style, but block themes work differently.
As with block styles, there is no standard onion to remove variations in unwanted style.
Let’s start with the simplest methods and work from there. What makes style variations so easy to ‘register’ or add to a block theme is exactly what makes it very difficult to ‘not register’. Consequently, we have a few approaches.
Remove a variation of a theme style
There are a few ways to Evening Style variation in a block theme such as TT5.
If you do not use an underlying theme, the most direct option is to delete the corresponding .json File from the parent theme. For example remove 01-evening.json from the /styles Directory completely removes the evening variation.
However, this is not recommended because the file will probably return after the next theme update.
A better, safer method is to use an underlying theme and to ignore the style variation. You can do this by making an empty file in the same path with the same file name. To ignore 01-evening.jsonAdd an empty file called 01-evening.json In the theme of your child /styles Directory.
This approach does not really “register” the variation; It just neutralizes it. WordPress still recognizes the file, but because it does not contain settings, the variation becomes invisible in the user interface and non-functional. This override only works because children’s themes load after parent themes, so it is worth confirming that your child theme is set correctly.
Hide a variation with CSS
Another solution is to hide the style variation for the user interface with the help of CSS. This does not remove it from memory or the rest of API, and it does not reduce the front-end Bloat, but it will prevent users from selecting it in the site editor.
Here is an example to hide the evening variation:
/* Hide specific global style variations in the Site Editor */
.edit-site-global-styles-variations_item[data-slug="morning"],
.edit-site-global-styles-variations_item[data-name="evening"],
.edit-site-global-styles-variations_item[title="Evening"],
.edit-site-global-styles-variations_item[aria-label*="Evening"] {
display: none !important;
opacity: 0 !important;
pointer-events: none !important;
}This works in the Editor > Style > Leaf styles panel. If a user has previously activated the evening variation, it is still applied, but they cannot re -select or re -switch it.
Hide a variation with JavaScript
You can also use JavaScript to hide the variation, injected via PHP using wp_add_inline_script. This is a bit of a hack, because style variations are registered in PHP, but it is sometimes the only practical way to reliably manipulate the user interface.
Here is a working example:
// Inject JS to hide specific style variations in the Site Editor UI
add_action('enqueue_block_editor_assets', function () {
wp_add_inline_script(
'unregister-core-blocks',
<< {
const interval = setInterval(() => {
document.querySelectorAll(
'[aria-label*="Noon"], [title*="Evening"], [data-name="noon"], [data-slug="evening"]'
).forEach(el => {
el.style.display = 'none';
});
}, 500);
// Stop the interval after 5 seconds
setTimeout(() => clearInterval(interval), 5000);
});
JS
);
});This script waits until the Dom is loaded and then scans repeatedly and hides the variation for a few seconds. It is fragile (because it depends on timing and class names), but it works when you have to suppress specific variations without touching the file system.
Summary
Keeping your site clean and free from unused elements improves the user experience and, in many cases, site performance.
Our examples here offer solid approaches of non -register -style variations. We hope that they also provide insights into why un registration can be confusing.
Looking for fast, reliable WordPress hosting while you build and test custom themes? Kinsta offers developer -friendly functions, staging environments and performance -optimized infrastructure to support your workflow from local devant to production.
#registration #style #variations #WordPress #block #theme


