how to add a php page in wordpress as template
1. Create Your PHP Template File
-
Go to your active theme folder (usually in
wp-content/themes/your-theme/). -
Create a new PHP file, e.g.,
custom-template.php.
2. Add a Template Header Comment
At the top of your PHP file, you must include a special comment so WordPress recognizes it as a template:
-
Template Name: This is the name that will appear in WordPress when you select a template.
-
Description: Optional, but useful.
3. Add the Standard WordPress Page Structure
Typically, your template will include the header, footer, and main content area:
You can now add custom HTML, CSS, and PHP code inside this template.
4. Upload/Place the File in Your Theme
-
Ensure the file is inside your active theme folder.
-
Example path:
wp-content/themes/your-active-theme/custom-template.php
5. Assign the Template to a Page
-
Go to WordPress admin → Pages → Add New (or edit an existing page).
-
On the right side, in the Page Attributes box, you’ll see a Template dropdown.
-
Select your template (e.g., “Custom Template”).
-
Publish/Update the page.
6. Optional: Add Custom CSS/JS
You can enqueue custom CSS or JS specifically for this template using functions.php:
âś… After these steps, WordPress will use your custom template for that page.