添加要在自定义帖子类型上显示的自定义模板文件

时间:2018-11-07 16:23:42

标签: wordpress

因此,我创建了自定义Location帖子类型和自定义Location Page Template,但是无法将Location Page Template分配给Location帖子。

我的Location Page Template的顶部看起来像这样:

/* Template Name: Location Template Post Type: Location * */

我需要这样的functions.php文件中的模板:

require get_stylesheet_directory() . '/inc/locations.php';

有人对此有任何经验吗?

1 个答案:

答案 0 :(得分:0)

我不是使用Location Page Template,而是使用WordPress模板层次结构,而是使用single-[posttype].php,因此在我的情况下,是single-locations.php。下面链接的图是有用的参考。 http://codex.wordpress.org/images/1/18/Template_Hierarchy.png