Customizing a page template

On an average page, we may want to display the page title. The home page is a special page of course. Let's prepare a custom template for it.

In the following steps, we'll set up a custom page template that will remove the page heading and bring in a custom template for our page contents. We'll equip the custom content template with the markup structure we need for the carousel and columns:

  1. In the main themes folder, find the template-custom.php file. This is a sample page template that's easy for us to adapt.
  2. Make a copy of it and rename it page-home.php as shown in the following screenshot:
    Customizing a page template
  3. Open the new page-home.php file in your editor and edit the opening comment, changing the template name to Homepage Template:
    /*
    Template Name: Homepage Template
    */
  4. Save the file.
  5. Now, back in your WordPress Dashboard, edit the page named Home. Change its page template to the newly created Homepage Template.
    Customizing a page template
  6. Update the page.
  7. There is no need to view the page in your browser yet as nothing will be different. Let's first make a change to the template.
  8. In your code editor, with page-home.php open, find the following line of code:
    <?php get_template_part('templates/page', 'header'), ?>
  9. This is the first of two lines of PHP. This first line pulls in the page title. (The template for this is found in the page-header.php file inside the templates folder.) Thus, we can remove the page title by simply removing the first line or commenting it out. Here I've used a single-line comment to comment out the call for the page header as follows:
    <?php // get_template_part('templates/page', 'header'), ?>
    <?php get_template_part('templates/content', 'page'), ?>
  10. Save the file. View and refresh the Home page in your browser. You should see the page title disappear as shown in the following screenshot:
    Customizing a page template

That's a start! Now to free our carousel from its bounding container element.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset