WordPress. How to create page templates
March 31, 0204
本教程将向您展示如何在WordPress中添加新的页面模板 Cherry Framework template.
WordPress. How to create page templates
-
登录你的WordPress管理面板.
-
Go to the Pages -> Add New 菜单以使用新页面模板创建新页面.
-
给你的新页面起一个标题并保存. In the Page Attributes 面板中,您可以从模板中已经包含的页面模板中选择一个页面模板. 你需要在这个列表中添加一个新的. 所有这些页面模板都位于 wp-content /主题/ CherryFramework folder on your FTP. 控件中添加一个新的页面模板 wp-content/themes/theme##### folder on your FTP.
-
Create a new file in any .php editor 如Dreamweaver或notepad++,并给它起一个名字,e.g. new.php. 增加以下内容:
-
保存该文件并将其上传到 wp-content/themes/theme##### folder on your FTP.
-
回到你在WordPress中创建的页面. In the Page Attributes 面板,你可以选择名为“Custom”的新页面模板.
-
Click Publish. Then click Preview Changes. 页面将完全空白.
-
Go back to your new.PHP文件开始添加内容. 该文件可能包含您需要的任何内容,包括一些 static content 或者一些决定页面内容的标记.
-
中的其他页面模板中的元素也可以使用 wp-content /主题/ CherryFramework 文件夹以创建唯一的页面.
-
Let’s first add a header and footer to it:
-
如果您保存更改,您可以在页面上看到它们:
-
现在您需要决定希望在该页面上看到什么样的内容. 假设您没有“Our Team”自定义帖子的单独页面模板. And you really like the layout 的感言页面模板,并希望看到“团队”自定义帖子相同 layout. Under the Appearance -> Editor 菜单,您可以很容易地确定用于推荐页面模板的文件名称. It is page-testi.php.
-
Open this file to edit. 只复制内容部分,因为我们已经有 header and footer (这只是一个例子,所以你的代码可能会有所不同):
-
Add the content to the new.php file. Rename: Template Name: Custom to Template Name: Team
-
Change page-testi.php to new.php in the code.
-
该代码还包含对loop/loop-testi的引用.php file. 这是另一个需要复制的文件. Copy loop-testi.php from wp-content /主题/ CherryFramework /循环. And paste it to the # # # # # wp-content /主题/主题/循环 folder (if there is no loop 文件夹,你需要创建它). Rename the file to e.g. loop-new.php and open it for editing. Change the word “testi” 在这个文件的任何地方进行“团队”并保存更改. (你可以使用Control (Command) + F).
-
Since the loop-new.PHP创建和修改完成后,可以回到 new.php file and change loop/loop-testi.php to loop/loop-new.php in the code. 完成的代码看起来像这样:
-
保存更改并检查新页面. 它应该有团队自定义的职位上的感言 layout page.
请随时查看下面的详细视频教程:
WordPress. How to create page templates
如果你想找一个专业的高级主题 website, take a look at design wordpress templates. Or check out a wide variety of WordPress templates page 为了更漂亮的设计.