3.4. Posts and Pages’ Templates

We said singular.php is going to grab content.php to show our single posts (and pages); but there’s more to it.

The Twenty Twenty has three (custom) templates to display posts and pages: Default, Full Width and the Cover template. As we saw before, we choose these ones in the editor.

Templates

We also saw the theme has a folder for those templates named “templates“; if we open it, we can see it has two files: one for the Full Width Template and another one for the Cover Template.

So, where is the template for the Default Template?

Default Template

Since there’s no template for it, according to the WordPress Hierarchy, the theme will use singular.php and grab content.php, as we mentioned before.

Full Width Template

In template-full-width.php, we can see it calls for singular.php, which means that content.php is used both for posts and pages with default and full width template.

Cover Template

For posts and pages with the “Cover Template”, however, the Twenty Twenty theme has another template part: content-cover.php.

Template Parts

If we take a look at the folder template-parts, we’ll see those two template parts, and all the other ones the theme has:

Conclusion

Following the pieces of the puzzle, as we’ll see in the last lesson of this section, is a great way to find elements so we can construct the selectors we need.

It’s a long road, I know; we’ll see a simpler way to do the same in the next section; however, what we can learn about the theme, PHP and WordPress functions, by reading the theme files, is what is going to truly helps us master the theme and any other “classic” theme we may want to customize.

Laly York. Neurodivergent Gen-X writer / B.Ed. / Lawyer. Writing, coding and taking pics. From Jupiter, living in a soap opera; flying on the web with three blogs.

JOIN COMMENTS

Any thoughts?