简体   繁体   English

在WordPress中创建自定义页面模板

[英]Creating a custom page template in WordPress

I'm using the twentyfourteen theme and have created a child theme with its own style.css. 我正在使用二十十四个主题,并使用自己的style.css创建了一个子主题。 Now I'd like to create a custom page template. 现在,我想创建一个自定义页面模板。 From all I've read the process seems to be: 从我已经阅读的所有内容来看,该过程似乎是:

  1. Make a copy of the existing page template, eg, page.php, and place it still in the parent theme directory but give it a new name. 制作现有页面模板的副本,例如page.php,并将其仍放置在父主题目录中,但给它一个新名称。
  2. Make the changes you want to this new template. 对这个新模板进行更改。
  3. Any elements you create can be given unique classes and then styled by the style.css in the child theme. 您创建的任何元素都可以被赋予唯一的类,然后由子主题中的style.css设置样式。

Does that sound right? 听起来对吗?

One question is, How is the new template assigned to the page? 一个问题是,如何将新模板分配给页面? Do I have to manually go into the Page Attributes and select the new template, or will it get pulled automatically from the template hierarchy? 我是否必须手动进入“页面属性”并选择新模板,还是会自动从模板层次结构中提取它?

Thanks for your help. 谢谢你的帮助。

You have to choose in the Page Attributes section. 您必须在“ Page Attributes部分中进行选择。 Refer the below URL. 请参考以下URL。 https://developer.wordpress.org/themes/template-files-section/page-template-files/page-templates/ http://www.smashingmagazine.com/2015/06/wordpress-custom-page-templates/ https://developer.wordpress.org/themes/template-files-section/page-template-files/page-templates/ http://www.smashingmagazine.com/2015/06/wordpress-custom-page-templates/

Custom page template 自定义页面模板

  1. page-{slug}.php 页面-{slug} .php
  2. page-{id}.php 页面-{id} .php
  3. page.php page.php
  4. index.php index.php

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM