August used to be a large month for WordPress. WordPress 7 ...
Closing yr, WordPress.com presented new code editors for the block editor and the Further CSS enter field within the WordPress admin. This was once the primary level of a bigger effort to make enhancing code a extra stress-free revel in.
These days, I’m satisfied to announce the release of the second one level of that effort: introducing the brand new and advanced Code block.
This isn’t a brand new block. It’s an enhancement to the present Code block that you just’ve most likely already been the usage of, which incorporates a number of enhancements over the unique:
You shouldn’t have to allow anything else to start the usage of the brand new model of the Code block. It’s already to be had to make use of. Simply insert the Code block any place within the block editor and upload your code.
By way of default, when including a Code block and putting code, you’re going to see your code in Simple Textual content:

After all, Simple Textual content doesn’t come with any syntax highlighting because it’s no longer a language. To modify this, make a choice a code language from the Settings → Language dropdown within the sidebar:

Syntax highlighting will then be carried out in response to the language that you just decided on, making the code a lot more readable for each you and your guests!
Professional tip: When you kind 3 backticks adopted by way of the language identify (e.g., ```php) after which hit Input, the editor will mechanically create a brand new Code block example and auto-fill the Language atmosphere.
If you wish to kick your Code block’s options up a notch, you’ll be able to additionally configure a number of different settings but even so the language:
This will likely make your web page’s code examples a lot more reader pleasant:

There are more than one techniques to customise the syntax highlighting and colours proven with the improved Code block. On this phase, I’ll stroll you via every from the fastest/most simple to the extra complicated ways.
The Code block ships with 4 block types out of the field:
Topics too can check in further types. Settling on this type of types is the fastest approach to alternate how your Code block is output:


You’ll be able to additionally customise the colours immediately from the editor by way of the Kinds → Colour panel within the block sidebar. The block has an intensive array of shade choices for customizing each facet of the syntax highlighting:

You aren’t restricted to just colours both. You’ll be able to customise any of the opposite to be had types, equivalent to Typography, Border, and extra. Those choices haven’t modified with the newest enhancement.
When you’re a developer or theme creator, you’ll in all probability need to outline default syntax colours and different types for the default output of the block. theme.json reinforce is integrated with this batch of improvements.
Right here’s what my customized Code block types appear to be after a couple of tweaks in theme.json:

For the reason that WordPress device itself doesn’t reinforce customized colours by way of theme.json, the builders at WordPress.com in-built customized reinforce for this option.
You’ll be able to customise any of the syntax colours by way of settings.customized.core/code in theme.json. That is an object the place every secret’s the syntax shade identify and the worth is the colour itself.
Right here’s an instance snippet that you’ll be able to use to customise your individual colours:
Any legitimate CSS shade is supported, so that you’re no longer restricted to hex shade codes. Use CSS customized homes, RGBA, and extra.
If you wish to borrow my complete theme.json customizations, replica and paste the next code. It comprises further customized types to make the Code block even nicer:
Whether or not you’re publishing snippets or full-blown tutorials, the improved Code block makes sharing and styling code in WordPress.com smoother and extra customizable than ever earlier than.
Syntax highlighting, block types, and customized shade choices put you in complete regulate of ways your code seems.
With those enhancements, you’ll be able to focal point much less on formatting and extra on writing nice content material that is helping your readers be told and construct.
August used to be a large month for WordPress. WordPress 7 ...
August 14 – 27, 2026 Welcome again to the WordPr ...
You'll now set up your WordPress.com web page from Ch ...
Lifetime Membership with Unlimited Access