Home > CMS Tutorial > WordPress > body text

How to create a new page template in wordpress

下次还敢
Release: 2024-04-15 16:12:14
Original
982 people have browsed it

Steps to create a new WordPress page template: Create a text file and name it template-name.php. Add code, including template name, header, footer, and custom content. Save the file to your theme's /templates folder. Refresh the backend and select a template on the New Page screen.

How to create a new page template in wordpress

How to create a new WordPress page template

WordPress page templates are pre-designed templates used to create a specific format or layout page. These templates are typically used to create custom landing pages, archive pages, or blog post list pages.

To create a new WordPress page template, follow these steps:

Step 1: Create a new file

  1. Use a text editor, Like Notepad or Sublime Text, create a new text file.
  2. Name the file template-name.php, where template-name is the template name of your choice.

Step 2: Add Template Content

Paste the following code in the text file:

<code class="php"><?php
/*
Template Name: 我的新模板
*/
get_header();

// 此处放置您的模板内容

get_footer();
?></code>
Copy after login
  • Template Name : This line specifies the name of the template that will be displayed on the New Page screen. The
  • get_header(); and get_footer(); functions contain the header and footer parts respectively.

Step 3: Place the template content

in the get_header(); and get_footer(); functions place your template content in between. This can include any HTML, PHP and WordPress functions.

Step 4: Save the File

Save the text file into the /templates folder of your WordPress theme directory.

Step 5: Refresh Page

Refresh your WordPress backend and go to the New Page screen. You should now see the new template you created appear in the Templates drop-down list in the Page Properties box.

Step 6: Use a template

Choose your new template and create a new page. WordPress will use this template to render the page.

The above is the detailed content of How to create a new page template in wordpress. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!