Home CMS Tutorial WordPress How to create a new page template in wordpress

How to create a new page template in wordpress

Apr 15, 2024 pm 04:12 PM
sublime wordpress

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:

<?php
/*
Template Name: 我的新模板
*/
get_header();

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

get_footer();
?>
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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP vs. Flutter: The best choice for mobile development PHP vs. Flutter: The best choice for mobile development May 06, 2024 pm 10:45 PM

PHP and Flutter are popular technologies for mobile development. Flutter excels in cross-platform capabilities, performance and user interface, and is suitable for applications that require high performance, cross-platform and customized UI. PHP is suitable for server-side applications with lower performance and not cross-platform.

What should I use to open html? What should I use to open html? Apr 21, 2024 am 11:33 AM

To open HTML files you need to use a browser such as Google Chrome or Mozilla Firefox. To open an HTML file using a browser, follow these steps: 1. Open your browser. 2. Drag and drop the HTML file into the browser window, or click the File menu and select Open.

What software is good for python programming? What software is good for python programming? Apr 20, 2024 pm 08:11 PM

IDLE and Jupyter Notebook are recommended for beginners, and PyCharm, Visual Studio Code and Sublime Text are recommended for intermediate/advanced students. Cloud IDEs Google Colab and Binder provide interactive Python environments. Other recommendations include Anaconda Navigator, Spyder, and Wing IDE. Selection criteria include skill level, project size and personal preference.

How to use the copied code in python How to use the copied code in python Apr 20, 2024 pm 06:26 PM

Here are the steps to use copied code in Python: Copy and paste the code into a text editor. Create a Python file. Run the code from the command line. Understand what the code is for and how it works. Modify the code as needed and rerun it.

How to open local file in html How to open local file in html Apr 22, 2024 am 09:39 AM

HTML can be used to open local files as follows: Create a .html file and import the jQuery library. Create an input field that allows the user to select a file. Listen to the file selection event and use a FileReader() object to read the file contents. Display the read file contents on the web page.

How to create py file in python How to create py file in python May 05, 2024 pm 07:57 PM

Steps to create a .py file in Python: Open a text editor (such as Notepad, TextMate, or Sublime Text). Create a new file and enter the Python code, paying attention to indentation and syntax. When saving the file, use a .py extension (for example, my_script.py).

In which folder are wordpress articles located? In which folder are wordpress articles located? Apr 16, 2024 am 10:29 AM

WordPress posts are stored in the /wp-content/uploads folder. This folder uses subfolders to categorize different types of uploads, including articles organized by year, month, and article ID. Article files are stored in plain text format (.txt), and the filename usually includes its ID and title.

Where is the wordpress template file? Where is the wordpress template file? Apr 16, 2024 am 11:00 AM

WordPress template files are located in the /wp-content/themes/[theme name]/ directory. They are used to determine the appearance and functionality of the website, including header (header.php), footer (footer.php), main template (index.php), single article (single.php), page (page.php), Archive (archive.php), category (category.php), tag (tag.php), search (search.php) and 404 error page (404.php). By editing and modifying these files, you can customize the appearance of your WordPress website

See all articles