Skip to main content

How To Create a Custom Page Template in WordPress

Submitted by admin on Wed, 12/08/2021 - 13:12
wordpress Custom Page Template

What is default template file in WordPress

page.php of your theme is used to show default template page.

Why We Need Custom Page Template

You may need to display contents in different layouts and styles. Like I want a page template that has no sidebar. And for this we need different custom page template.

How To Create a Custom Page Template

  1. Let's create a new page template named Tutorial.
  2. Create a copy of page.php file of your theme and rename it as tutorial-template.php
  3. Open tutorial-template.php in any text editor. Add following codes at the top of page.
  4. 
    <?php
    /*
     Template Name: Tutorial
     */
    ?>
    
    
  5. Edit code of tutorial-template.php as per your requirements.

Done!!

Create a new page and now you can see this new template Tutorial as an template option.

Similarly you can create many custom page template files.

Category

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.