Creating a custom page template in WordPress

2019-09-11 18:50发布

I'm using the twentyfourteen theme and have created a child theme with its own 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, e.g., page.php, and place it still in the parent theme directory but give it a new name.
  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.

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.

标签: php wordpress
1条回答
你好瞎i
2楼-- · 2019-09-11 19:26

You have to choose in the Page Attributes section. Refer the below URL. 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
  2. page-{id}.php
  3. page.php
  4. index.php

enter image description here

查看更多
登录 后发表回答