我在wordpress中创建了几个自定义帖子类型,并将层次结构设置为true,因此它表现为页面 .
问题是,模板选择不是't available. I'已应用this hack以显示菜单:
wp-admin中有一个文件meta-boxes.php包含wordpress安装..文件的第547行,这是函数page_attributes_meta_box()只需添加对特定帖子类型名称的检查即可显示模板页面下拉 . if(('page'== $ post-> post_type ||'yourcustomposttype'== $ post-> post_type)&& 0!= count(get_page_templates())){
$ template =!empty($ post-> page_template)? $ post-> page_template:false;
?>
这成功使菜单出现,但数据不会保存 . “父”部分保存,但“模板”不保存 .
有没有人有任何想法?
2 回答
我已经使用过这个插件了,帖子还可以,试试吧:)
https://wordpress.org/extend/plugins/custom-post-template/
偶然发现这个问题寻找相同的功能 . 我知道这有点晚了,但我想我找到了解决方案 . 通过使用插件查看自述文件,您可以将其添加到functions.php中,以获取您正在寻找的功能 .