Discover in this tutorial how to modify the list block (of WordPress) so that its default configuration is numbered (ordered).
Often, when working with WordPress native blocks, we may find that certain default settings do not fully meet our needs. In particular, you may want that, when adding a list block, this is created by default as an ordered/numbered list so that you don’t always have to change it manually.
Are you interested? Read on.
Code to modify the list block default attributes
Add the following code at the end of functions.php or in your functionality plugin:
To see this and another 1091 code snippets of this website, login or subscribe here.
This snippet uses the block_type_metadata
filter to modify the default attributes of the list block in the WordPress block editor. Specifically, it checks if the current block is a list block(core/list
). If it is, it modifies the ordered
attribute so that, by default, the list is ordered(true
).
This is just an example, you can adjust it to your needs and see the specific attributes that each block has in the official documentation.
Conclusion
Now you know what steps to take to modify the default attributes of the list block in WordPress, so that whenever you add this block it will be generated in principle as an ordered list.
This change will affect all new list blocks you add in the WordPress editor, making it easier for you to create content on your website.
Any questions? I read you in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉