I’m just getting started so forgive the dumb question. I used to be a programmer so have a general idea of what’s going on but struggling to get this concept in WP. I’ve searched the web and built a few sample pages to try to answer this but still can’t figure it out.
I understand that templates are supposed to impose a consistent look and feel to a site. I’ve downloaded a theme that contains templates for ‘front page’, ‘Index’, ‘all archives’, ‘pages’, ‘search results’, ‘single posts’, etc. They look very appropriate for what I need (when looking at the collection of templates in the ‘manage templates’ view).
When I create a new page, I was expecting to be able to choose what template to use to ‘build’ or ‘constrain’ that page, but every page I create shows (on the right) template: ‘Pages’, and clicking on that ‘Pages’ object lets me edit or create new template, but not select a pre-existing template. Further – when I create a new page, I’m offered a set of ‘pre-defined layouts’ such as ‘store’, ‘contact’, ‘about’, ‘Blog Posts’, etc. Some of these ‘layouts’ look remarkably similar to what I see in ‘templates’ (eg, ‘all archives’ template, ‘blog posts’ layout).
Specific example of what I’m trying to do: I want to build an ‘index’ of my pages, and of my posts. The ‘Index’ template looks perfect for what I want for my ‘pages’, and the ‘all archives’ template looks perfect for what I want for my ‘posts’. But I’ve never found any way to ‘invoke’ or ‘apply’ these templates. Conversely, I went to create a new page and, as noted, there was a ‘Blog Posts’ ‘layout’ that was close to what I wanted (for posts), and it pretty much does what I want. But I can’t find a page layout that provides an index of pages the way I want it, and that’s why I want to use the ‘index’ template.
I just created a blank page, and on the right it says ‘Pages … Displays a static page unless a custom template has been applied to that page or a dedicated template exists’. This strongly suggests that I should be able to apply a template, but I cannot figure out for the life of me how!
I understand that ‘layouts’ are just starting points for pages, but I can’t understand exactly what role ‘templates’ play, since I can’t apply them to a page, or pick one explicitly. NOTE – I’m using the ‘block’ (gutenberg?) editor.
[ad_2]
Have you read the WP developer documentation? Start there.
I’ve made some progress. I created a new template, from scratch, and now, when I edit or create any page, I can click on ‘Template’ on the right, and see ‘swap template’. The only template shown that I can ‘swap to’ is the template I created. So the behavior is as if, the templates that came with the ‘theme’ are hidden, but any new template I create is fair game to be a template that I can ‘swap to’. All the documentation talks about all templates in the same way – I’ve seen nothing to suggest ‘some’ templates are reserved or hidden.
This makes no sense as the template I created is fundamentally no different from one of the ‘included’ templates (my ultimate goal is to build a slightly different template, while preserving the ‘as delivered (in theme) template ‘as is’). I was also able to copy the existing template (index) into a new template using the ‘copy blocks’ command in the editor, and I was able to ‘swap to’ that new template also. So it really seems like WP doesn’t allow you to swap to a pre-delivered template but does allow you to swap to any template you create yourself.
So is there a reason that ‘included’ templates are somehow prevented from being ‘swapped to’?