Add a new page template wordpress

To add a new page template in WordPress, you can follow these steps:

Method 1: Using the WordPress Theme Editor

  1. Log in to your WordPress dashboard.
  2. Go to Appearance > Theme Editor.
  3. Click on the Templates tab.
  4. Click on the Add New button.
  5. Give your new template a name (e.g., "My New Page Template").
  6. Choose a template type (e.g., "Page").
  7. Click Create Template.

This will create a new PHP file in your theme's page-templates directory. You can now edit this file to create your custom page template.

Method 2: Creating a new PHP file

  1. Log in to your WordPress dashboard.
  2. Go to File Manager (or use an FTP client like FileZilla).
  3. Navigate to your theme's directory (e.g., wp-content/themes/your-theme).
  4. Create a new folder called page-templates if it doesn't already exist.
  5. Inside the page-templates folder, create a new PHP file with a name that starts with page- (e.g., page-my-new-template.php).
  6. Open the file in a code editor and add your custom page template code.

Example Code

Here's an example of what your new page template file might look like:

<?php
/*
Template Name: My New Page Template
*/
?>

<!-- Your custom page template code goes here -->
<h1>Welcome to my new page template!</h1>
<p>This is a custom page template.</p>

Assigning the new page template to a page

  1. Go to Pages > All Pages.
  2. Click on the page you want to assign the new template to.
  3. Click on the Edit button.
  4. In the Page Attributes meta box, click on the Template dropdown menu.
  5. Select your new page template (e.g., "My New Page Template").

Your page should now use the new template.

Tips and Variations