Hierarchy of templates - Wordpress

Asked

Viewed 139 times

0

I would like to know simply, easily understood, if someone can explain about the hierarchy of WP templates. I’ve seen a lot about it, including the image of the documentation, but for some questions, how much to use Archive.php for example and tals.

If anyone has a better explanation about...

1 answer

1

Fala Peter.

As you yourself mentioned, the documentation image already gives a good help. I will make a possible path and you answer with questions if you have. So, basically just create the files in the folder that Wordpress makes the selection.

The image

Imagem da documentação

General rule

Basically, Wordpress will follow from left to right, trying to find the appropriate template, according to the alternatives.

Let’s assume you have a tag created "books I read". So when you type in the address:

sitecombr/livrosqueli

  1. Wordpress will check whether what you are seeking is an author, category, custom post, taxonomy, date or tag. In our case it is a tag.
  2. Next step is to find out if you have a file in your theme root directory called "tag-librosqueli.php" or "tag-id_da_tag".
  3. If not, try to find the file "php tag.".
  4. If not found, Wordpress will try to use the file "Archive.php", if you have paging, you will use the "paged.php".
  5. If all fails, Wordpress uses the default "index php.".

Use of basic templates

  • Archive.php

    Used to display post groups. Example: Last blog posts.

  • single php.

    Used to display the content of a post. Example: When the visitor clicks on a post within a list of posts.

  • page php.

    Used to display static pages. Example: Display institutional pages like "Who We Are", "About", "Contact"...

  • home php.

    Used to display home posts. If you have set a static page as the home page, the template used will be the front-page.php.

  • comments-popup.php

    Used to display comments from a post when opened via popup (I don’t think I’ve ever used this template, rs).

  • 404.php

    Used to display specific content when a post is not found.

  • search php.

    Used to display the results of a site search.

Absss!

  • Wow, Leonel blazon? So I understood your explanation, it was more or less what I imagined. But my question is more in Archive.php for now, like this: Here at the company a friend has developed a website and at a certain place he used Archive.php, and when I asked, said that was pq the Archive.php is for a set of items, list. Anyway, it’s a mess in my head, when it’s best to use this or that, the pq and tals...

  • Speak Peter. I edited the answer see if it helped you. : D

  • Thank you very much, Leonel. My last question is the following, let’s assume, that you have to have a page that talks about the customer, for example and it will contain items. In case I’ll do type Archive-biography.php, and in that file I’ll loop or whatever neh?! E ae, how will I make this Rchive to be called in the biography menu? Pq thought that in the menu, I could only call if it was the same page and such... Note: I don’t know if I can explain what I have in my head... Basically, how to make clear that in a certain place will have to appear the Archive-biography...

  • I understood that the WP goes one way to reach a given file, or the index as the last one, if it doesn’t have what it would have to be. But the bid is only how to make such Archive.php appear at a certain place...

  • This is @Peterroberto. First, what kind of information is "Biography"? Is it a post category? A tag? A custom post type? Identifying this, you go to the image diagram and search, for example: If it is a "category", you will use the template: "Category-biography.php". If it is a tag: "tag-biography.php". To appear in the menu: 1. Go to "Appearance > Menus". 2. Check all boxes in the retractable "Screen Options" menu (Top right corner). 3. Then you can select the items from the left menus and add to your menu.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.