custome page template

10
WordPress Custom Page Template

Upload: lucky-ali

Post on 18-May-2015

374 views

Category:

Education


1 download

DESCRIPTION

WordPress Slides

TRANSCRIPT

Page 1: Custome page template

WordPress

Custom Page Template

Page 2: Custome page template

What is a Page template?

You'll probably want most of your website Pages to look about the same. Sometimes, though, you may need a specific Page, or a group of Pages, to display or behave differently. This is easily accomplished with Page Templates.

Selecting A page template?

Your Theme files should include a default page template (named: page.php). Your Theme may also have one or more custom page templates, for instance, to display content in wider columns. Or you may have created a custom template of your own.

Page 3: Custome page template

Steps to Select page template.

Go to Dashboard Pages Edit page

Page 4: Custome page template

In Edit page area. You will se a widget called “Page attributes”On the right side. Which have the built in page templates by default. If you create a custom page template i.e. page template according to your own needs, that will also appear in the same dropdown menu.

You can select the desired page template for concerned page and update the changing. Look and behavior of the page will be according to the selected page template

Page 5: Custome page template

How to Create own page template in child?

Adding new page template is very easy in scratch development. You only have to find some files and copy /paste the code. We will perform this with an example!

you are supposed to have a well running child theme with all necessary files. i.e. styles.css etc.

Follow these steps!

1. Find page.php in the parent theme folder. Copy this file and paste it in Child theme folder with specific name . We will name this file as “No-title Page-Template”. As the name describes that the pages with this template will not have title of the page!

Page 6: Custome page template

Open this file. And look at the code . You will see the commented code in the start , some conditional functions and some other code in this file.

Step 2. Delete all commented code and add only following line in the start of your

template file./*

Template Name: No-Title-Page-template */

Page 7: Custome page template

if you look at the remaining code you can see that there are some get Functions for other files that are, get_header () , get_sidebar(), get_footer()etc. Title and post of the page are parts of page contents. Here you can see that

<?php get_template_part ( ‘ content’, ‘page’); ?>This is the code taking the content from the content-page.php.

Content-page.php file contains the content of the page, including title posts etc.

Page 8: Custome page template

Step 3. you Find the Content-page.php in the parent theme folder and open this file in dream viewer or some other code editor.

Copy all the code except commented. And replace this copied code with

<?php get_template_part ( ‘ content’, ‘page’); ?>In No-Title-Page-Template file

Page 9: Custome page template

After replacing <?php get_template_part ( ‘ content’, ‘page’); ?>With copied code, newly created template file named “No-Title-Page-Template.php” will look like this.

Page 10: Custome page template

Step 4. Now find the code which is adding the title. And delete it. In our Template file

Now, Your custom page template is ready. This template will make your site page not to show the title.