V
V
Vitya Podpriklopolny2019-02-09 12:53:16
CMS
Vitya Podpriklopolny, 2019-02-09 12:53:16

How to deal with WordPress templates?

Hi
I'm learning WordPress and I'm completely confused. I have a multi-page website (not a blog). It turns out that for each page you need to create page-(name).php and then select a template from them in the admin panel? And then just select a static page in the settings? Did I understand correctly? Or is this not the right approach?
If so for each page to create, then why then index.php and so on? How can I select index.php as the blog page with a static page?
Please help me figure this out! Couldn't find a good explanation anywhere. Just an explanation of the structure, not how to use it.
Thank you very much in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan Hasanli, 2019-02-09
@megamage

Получается, что для каждой страницы нужно создавать page-(name).php и потом в админке выбирать у них шаблон?

Not necessary. Explore the template hierarchy. Index.php is responsible for displaying the content of the pages, if there is
no page.php template.
it is enough to create a page.php template, as it will be assigned by default for pages.
The single.php template is responsible for displaying a single record.
The archive.php template is responsible for displaying an archive or category . The archive.php template is responsible
for displaying a category (category) if there is no category.php template.
For displaying the main page depending on the settings (Settings - Reading - Main static or display latest posts) templates front-page.php (if static), home.php (if dynamic) can respond. And if there are no these templates, then page.php will be used and if the latter is absent, index.php will be used
https://developer.wordpress.org/themes/basics/temp...
Create templates page-{slug}.php single-{slug}.php page-[id].php single-[id].php and others "refining templates" is needed if you want the template of a given page to be different.
In the above templates, there is no need to select them in the admin panel for the page.
However, you can create a template with any name and add the desired title
. And then you can select it in the admin panel for the desired page / pages.
Useful links - https://codex.wordpress.org/Theme_Development

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question