CREATING BLOCK TEMPLATES IN WORDPRESS

When a website operates as intended, what happens behind the scenes is beyond fascinating. In WordPress, the intuitive content management platform, that process may even be more so.

Utilizing custom templates in PHP with WordPress 5.9, Developers have simplified once complicated processes. One such process is how to create and edit blocks using the Block Editor and Full Site Editing, and HostRooster wants to show you how. To do that, we must first understand what a template is.

WordPress developers define template files as “modular, reusable files used to generate the web pages on your WordPress site.” As such, it becomes easier to see that templates are present throughout WordPress themes, from the home page down to how the 404 page pops up. To customize a template or specific parts of it, however, a custom template is needed. 

In the pursuit of creating a custom template, it is important to note that WordPress employs the use of a Template Hierarchy for data retrieval. This must be considered when a template is being created, as it decides which template file is best used on a particular page or post.

Acquiring block templates

With Full Site Editing themes such as Twenty Twenty Two, you can insert and activate a block theme for your template by navigating to Appearances > Editor > Site Icon > Templates.

In addition to the ‘Add New’ function which will appear in the upper right corner of the platform, you will also gain access to all currently functional templates on your site. Furthermore, you can access relevant details about a template, such as its user, plugin or theme, from that section of the dashboard.

Making changes to a block template

Select the block template you wish to modify and access List View. From there you can add, modify, style, lock and remove blocks, similar to the functionalities of the Post Editor.

How to create a new block template

Navigate to Appearance > Editor > Add New > Author. Next, add a header and footer, and follow that up with the addition of a Query Loop Block. As you will observe, the Query Loop block options contain a toggle switch to inherit queries from template – a function aimed at ensuring the Query Loop Block correctly identifies a specific author’s template, thereby filtering the results based on that author’s posts.

There have been significant leaps in the creation process concerning blocks and other WordPress elements. These leaps have almost entirely removed the need for users to be versed in PHP, as was previously the case. Now, with responsive block themes such as Twenty Twenty Two, you have more freedom to examine templates as well customize the looks and feel of your own. Get to exploring.

HostRooster is a leading web hosting solutions company. Since our founding in 2019, HostRooster has continually innovated new ways to deliver on our mission: to empower people to fully harness the web. Based in London, England, we provide comprehensive tools to users throughout the world so anyone, novice or pro, can get on the web and thrive with our web hosting packages.

%d bloggers like this: