How to create custom page template in WordPress

Custom page template should be used when you want a different layout on any page. There can be multiple reasons for actual uses in your site created on wordpress. This is simple and can be done by following below steps , you just need simple knowledge about php, html and css.

1. Create template file, let us take the example of creating a template where we can display all the posts from a particular category. Also User should be able to navigate easily to each post of that category.

a) Create a template file and add the below code,

b) Few things to note down which are following,

i. Template name must be defined and same name will appear on page while choosing the template
ii. Be cautious while writing the php code mixed with html code as these have different syntax
iii. Above code is used to display one post per page and previous/Next links appears on header and footer of page

2. Upload above file to your theme, under templates directory
wp-content/themes/(Your theme directory)/templates

3. Now you will be able to use the newly created templates on each page. For this go to admin panel of your WordPress site and create or open your page. Now go to template section on right pane, there you will be able to see the entry of new template named as ‘Category – Content’.

Thanks

Leave a Reply

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