2011-04-13 88 views
0

我在wordpress中创建了一些自定义帖子类型,并将层次设置为true,因此它的行为如同一个页面。为自定义帖子类型选择模板菜单?

问题是,模板选择不可用。我申请this hack拿到菜单出现:

有 可湿性粉剂管理员\包括WordPress的 安装..该文件的行547, 这是一个内部文件元boxes.php功能 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; 
     ?> 

这使得成功的菜单出现,但数据不会保存。 “父母”部分保存但“模板”不保存。

有没有人有任何想法?

回答

0

我用这个插件,这是确定上岗,试试吧:)

https://wordpress.org/extend/plugins/custom-post-template/

+0

欢呼声中,我已经得到了插件的运行,除非我失去了一些东西它不会做什么,我需要自定义文章类型 – jsims281 2011-04-14 08:55:19

+0

是的,但我认为它应该是可能有它做什么你想要一些小的修改。 – 2011-04-14 10:19:01

+0

最后我只是放弃了自定义的帖子类型,但我会将它标记为答案,因为它是(最好的)在这里。 – jsims281 2011-04-21 16:49:35

0

过这个问题,寻找相同的功能绊倒了。我知道这有点晚了,但我想我找到了解决办法。通过使用插件查看自述文件,您可以将其添加到您的functions.php中以查找所需的功能。

/** 
* Hooks the WP cpt_post_types filter 
* 
* @param array $post_types An array of post type names that the templates be used by 
* @return array The array of post type names that the templates be used by 
**/ 
function my_cpt_post_types($post_types) { 
    $post_types[] = 'movie'; 
    $post_types[] = 'actor'; 
    return $post_types; 
} 
add_filter('cpt_post_types', 'my_cpt_post_types'); 
相关问题