admin管理员组文章数量:1296483
Basic question, but I want to enable page templates. I have one theme which has page templates enabled. I switched to another but there is no option to change the template, even when creating a new page. How do I switch this option on? I've had a root around on the Codex and forum but can't find it.
Basic question, but I want to enable page templates. I have one theme which has page templates enabled. I switched to another but there is no option to change the template, even when creating a new page. How do I switch this option on? I've had a root around on the Codex and forum but can't find it.
Share Improve this question asked Mar 21, 2011 at 14:02 JohnnyBizzleJohnnyBizzle 4433 gold badges8 silver badges17 bronze badges4 Answers
Reset to default 9Chances are that the theme you've switched to has no page templates defined - they exist on a per theme basis.
Here's the Codex reference: https://wordpress/support/article/pages/
Define your template name in the custom template file.
<?php
/*
Template Name: demo
*/
?>
After this the select template option will be available on the edit screen. You can choose the desired name you want.
There is another reason why you may not see the Page Template
dropdown fiels in your page editor. If you are creating a global page template (one that can be used for any page, you need to ensure that you do not name of your template file with the page-
prefix, else WP interpret this as a special template for use on page slugs matching the rest of the name.
From the page template codex:
Important! Do not use page- as a prefix, as WordPress will interpret the file as a specialized template, meant to apply to only one page on your site.
and finally make sure you insert the following comment at the top of the page:
/* Template Name: Name-of-your-template */
Allow page template support to you theme by adding this function in your functions.php file:
function is_page_template( $template = '' ) {
$page_template = get_page_template_slug( get_queried_object_id() );
if ( empty( $template ) )
return (bool) $page_template;
if ( $template == $page_template )
return true;
if ( is_array( $template ) ) {
if ( ( in_array( 'default', $template, true ) && ! $page_template )
|| in_array( $page_template, $template, true )
) {
return true;
}
}
return ( 'default' === $template && ! $page_template );
}
本文标签: optionsEnable page templates How
版权声明:本文标题:options - Enable page templates. How? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741638903a2389800.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论