Customizing Page Templates in WordPress – lesson 23

Page templates in WordPress are very easy to add., if you need to style the template for all pages, then you can create a file page.php in the root of the theme. Let's create a file and put the code from the single.php file there. Template created, then you can remove and add something of your own (new design elements, additional sidebars, menu …).

That, what happened can be seen on the example of any previously created page, i clicked on the portfolio page and this is what it looks like now.

wordpress create page themplate

We'll talk about the portfolio page later., and now let's try to make templates for individual pages, those that we can then select in the admin panel.

If we need to make a template for a separate page, then you can use a special comment. This comment is a tag for wordpress, which indicates, that the file is an arbitrary pattern.

Let's try to start creating our page templates in order.

At the root of your theme, there is a file called onecolumn.html, rename it to tmp-onecolumn.php, prefix tmp we add, so that in the future you won’t get confused where the page templates are, where are the other files?. After renaming the file, add a comment like this to the top of the template:

wordpress create first themplate - Wordpress courses

Let's go through the steps already familiar from the previous lessons and replace the upper and lower parts of the code, include a header in the template file, footer, top and bottom of template.

wordpress create top area - Wordpress courses

create the bottom of the template - wordpress courses

In order for the template to start working, we must specify for which page it needs to be applied.. Go to the admin panel -> Pages -> about and select a new template and refresh the page.

Selecting a template on a wordpress page

You can see, what the page looks like in its current form but it does not display data yet, only outputs the contents of the tmp-onecolumn.php template. Let's point out together, what and where we will display in the template.

Replacing the content of the tag <section> to the code that we have already used in the page.php template, namely this one:

Further, if we look at the output of the material, we'll see, that the text on the page is shifted to the right, although we haven't inserted the thumbnail yet, this point needs to be fixed everywhere where we used the thumbnail output.

Thumbnail of my video codec output

Let's change this code:

On this one:

Before code change.

wordpress page without images

After code change.

wordpress page without thumbnail

I think, from the images above it is clear, what fix were you talking about?. Also fix the thumbnail output in archive.php files, single.php and page.php alone.

Good luck in website development, keep in touch, I'll tell you a lot more. In the next lesson I will tell, how to display a blog section on a separate page.

Sources of the current lesson

zip wordpress theme archive


Buy WordPress hosting
WordPress tutor
Online tutoring services. List of courses I teach
  • Basic web design course;
  • Site layout;
  • General course on CMS WordPress and continuation of the course on template development;
  • Website development in PHP.
Read more on the page WordPress tutor
*/

Nikolaenko Maxim

Director of web studies ProGrafika. I am developing, website design and promotion. Always glad to new blog readers and good clients.


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Templates for WordPress
The best hosting in Ukraine
Stable hosting for Drupal