HOW-TO: Creating groups of page for WordPress (Page Templates)

In the previous article I told you how to create to sidebar additional with the purpose of to be able to remove more yield to him to which samples in each page. Perhaps in a section of your Web you prefer to show to the last articles in the lateral bar but in another one a subscription form the blog. Nevertheless, to get to obtain this and to take advantage of you will to the maximum need it to know how to create groups for the pages of WordPress.

Exactly this last one is what we are going to see in this article and you will see that is even easier that the previous tutorial.

Creating groups will allow you to create new structures, from simplest and well-known as fullwidth until most complex than you can imagine. What seems to you if we began seeing how are created and later we looked for some ideas?

How to create Plantilla Personalizada or Page Warm up to you

To create a customized page is very simple and practically any person would have to be able to do it without problems, so you do not have any type of fear! 😉

In order to begin you have two options: to create a new file PHP or to duplicate classic page.php that you will find in the folder of your theme. I recommend two things to you to do the easiest life in the future to you:

  • It tries that the name of the file that you have created is most descriptive possible (page-fullwidth.php, no-sidebar.php, etc)
  • Themes for these modifications uses child, if you do not know how a look throws to this article

In order to finish only creating it (yes, we finished already) you will have to add something as the following thing:

<? php/* Tempers Yam to you: My customized group *? >

And it is already created. Or I told you that it was the more easy that to create to sidebar almost or just as to make your shortcodes ðŸ˜‰

In order to try that everything has left correctly you will have to add a new page to your WordPress and in the part œAttributes of page you will find a drop-down one with groups. There you will find the one that you finish creating with the name that is to him. In order to prove it we are going to insert something of HTML to see what so is, with a pair of line will be enough:

<? php/* Tempers Yam to you: My customized group *? > <h1>Mi customized page is leche</h1>

It prints the HTML correctly and as we can see allows to construct a page us totally cleans, without WP sign. The normal thing is that loop exists to show the information that we add when creating the page, the title and others¦ is very simple. If you have duplicated the file page.php you will know to what I talk about. In any case, it will depend on how we want to orient the group.

Adapting our group in the style of WordPress

Not to leave our so sober group we will give the same style him that to the rest of the Web. For it we will have to incorporate some basic elements of WP that are in charge to generate all the content with a pair of functions. A pair of lines more and¦

<? php/* Tempers Yam to you: My customized group * to get_header (); > <div id= " contained class= " contained " > <! -- From we showed the content here -->¦ </div> <? php to get_sidebar (); //We called when sidebar if we want to show it to get_footer (); >

With this we must have the group finished and prepared to use it under the same style that the rest of our subject. Evidently it is a very basic group that we will have to modify more if we want that it has some utility (in fact right now nor it will show the content of the page).

If you want to show the content of the page you will have to create a Loop, a look throws to the documentation of WordPress

Why it can serve to create a group

So that it has certain utility you will have to give a return him to which we have done in this tutorial. Create to me, this it is only the principle of that you can personalize so much as you want, but is necessary to start off from here.

Now that you know the system to create Page Templates in WP you will be able to create pages as¦

  • A listing of authors with information exceeds they and its publications
  • A ordered article list of a certain category as you want
  • A page that shows articles with certain labels
  • Page of testimonies or recommendations
  • The customized page of contact with a form, map and another information
  • ¦ and much more

Also it will serve you to even modify the design by means of CSS according to the group that is used or to play with conditional thanks to the function is_page_template (). All this I leave it in your hands, the best form to learn is practicing in your own projects 😉

Or you know, as always, any doubt or asks sends it through the commentaries. And if you have some idea in mind I would like to also read it! 😉

Commentaries

  • Amelia he says:

    Thanks for the contribution.
    I have created the group: contacto1
    In its interior I have placed: <? php/* Tempers Yam to you: contacto1 *? >
    I have created the page: Contact and I have inserted: [contact-form-7 id= " xxx title= " Contact form 1]
    Also I have tried placing in the page: <? php I throw do_shortcode (œ[contact-form-7 id= " xxx title= " Contact form 1]); >
    And it does not work.
    I have verified this code in a page of predetermined group and works perfectly.
    Not what I am doing bad.
    Thanks beforehand.

    • Wewokc he says:

      Hello Amelia,

      Does the group that you have created appear you in the drop-down one? If it appears you in the listing is that the group is well and perhaps the content is not it absolutely. It tries to add any flat text to see if you obtain that the page is in the navigator once loadings to which you have assigned the group to him, as it picks up the article.

      If you prefer to do it easy and to maintain the structure of the rest of pages you can duplicate to the file page.php, to change the slug to him (for example: page-contacto.php) and to add the name to him of the group as comment in the article. Later you will only have to modify the code to your ill 🙂

      If you are not able to solve you do not doubt it in returning to comment.

      A greeting and thanks to happen to you!

  • patricabaleiro it says:

    Hello, I have a group created already with my theme œBlog Left Sidebar but she is that if I apply it to a page to only shows me what there is in the blog, and not what I write in my page. It exactly makes the function that I want, but I would like that she showed the content to me of the page that I am creating. That it is what would have to change?

    • Wewokc he says:

      Hello patricabaleiro,

      Most probable it is than the group that you are selecting is exclusively for showing to the content of your entrances and not the one of the page. On that page never will be its content unless you modify the group.

      In order to create a page that shows what you write in easiest the visual publisher of wordpress it is than you duplicate to the file page.php that you will find in the folder of your subject and you modify it according to your necessity. I do not know the subject that you are using and how it will be its structure but I can help in something more you do not doubt you in commenting.

      A greeting!

  • Andrea Haro he says:

    Good morning,

    I have a created subject, there am it including as you indicate, but it does not appear me in the drop-down one and I cannot select it.

    That can be happening?

    I have including .php in the /wp-content/themes/spacious/page-templates directory

    A greeting,

It lets a commentary

To subscribe to me!

No, thanks.