2011-04-13 85 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'); 
相關問題