admin管理员组文章数量:1391960
So I have a custom post type that is called recipe
and then I have a page called /recipes/
- What would be the proper way to hook a template for my recipes page?
I have the file single-recipe.php
following the WordPress hierarchy with this inside:
<?php
/*
Template Name: Recipe
Template Post Type: post, page
*/
echo 'Hello';
But I'm not getting any templating output:
The below is my folder structure:
So I have a custom post type that is called recipe
and then I have a page called /recipes/
- What would be the proper way to hook a template for my recipes page?
I have the file single-recipe.php
following the WordPress hierarchy with this inside:
<?php
/*
Template Name: Recipe
Template Post Type: post, page
*/
echo 'Hello';
But I'm not getting any templating output:
The below is my folder structure:
Share Improve this question asked Feb 11, 2020 at 21:39 DevSemDevSem 2092 silver badges11 bronze badges 01 Answer
Reset to default 1The filename single-recipe.php
is telling WordPress "only use this file to display single 'recipe' CPT posts."
If you want to use it as a Page template, you can either rename the file tpl-recipe.php
(or something similar, it doesn't have to be this filename, it just has to not be a recognized pattern like single-cptslug.php
) - in which case you'll have to manually choose that template every time you create a new Recipe -
Or, you can have two files. One named single-recipe.php
which does NOT have the comments at the top, and one named tpl-recipe.php
(or similar) which DOES have the comments at the top.
本文标签: theme developmentTemplate Hierarchy for custom post type pages
版权声明:本文标题:theme development - Template Hierarchy for custom post type pages 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744757580a2623554.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论