2015-02-11 96 views
0

我已經註冊了一個自定義後類型:的WordPress 4.1:自定義文章類型將不會加載,鏈接不工作

<?php 
register_post_type('my_cpt_fiction', 
    array(
    'labels' => array(
     'name' => __('Custom Posts') 
     , 'singular_name' => __('Custom Post') 
     , 'add_new' => 'Add New' 
     , 'add_new_item' => 'Create a new Custom Post' 
     , 'edit' => 'Edit Custom Post' 
     , 'edit_item' => 'Edit Custom Post' 
     , 'new_item' => 'Create a new Custom Post,' 
     , 'view_item' => 'View Custom Post,' 
     , 'search_items' => 'Search Custom Post' 
     , 'not_found' => 'No Custom Posts found' 
     , 'not_found_in_trash' => 'No Custom Posts found in trash' 
    ), 
     'public' => true 
    , 'has_archive' => true 

    , 'supports' => Array(
     'title' => 'title' 
     , 'editor' => 'editor' 
     , 'author' => 'author' 
     , 'comments' => 'comments' 
    ) 
    , 'show_ui'    => true 
    , 'rewrite' => array('slug' => 'my_custom_post' , 'with_front' => false, 'feeds' => true) 
    , 'capability_type' => array('my_custom_post','my_custom_posts') 
    , 'map_meta_cap'  => true 
    , 'taxonomies' => array('category') 
    , 'publicly_queryable' => true 
    , 'exclude_from_search' => false 
    , 'query_var'   => true 
) 
); 

我沒有分類。

這添加到菜單中,我可以創建和編輯。但是,當我訪問到自定義帖子的鏈接時,它不會加載,而是看到主要的靜態主頁。

我已經嘗試過許多不同的永久鏈接組合,或者沒有永久鏈接。

我也似乎無法找到具體地表示,好像它是一個職位或頁面自定義後類型的任何信息,人們只是認爲它必須努力...

任何幫助,將不勝感激。

/J

回答

0

嘗試在init鉤子包裹它:

add_action('init', 'create_my_post_type'); 
function create_my_post_type() { 
    // Your code here 
} 

創造職位類型或改變之後,它在你的WordPress設置 - >永久鏈接是重寫設置,頭,點擊保存。這將重置您的重寫規則並重新創建.htaccess文件。

4

由於WordPress重寫規則,大多數情況下會發生這種情況,它們存儲在數據庫中,您需要刷新它們。

轉到設置 - 永久鏈接,只需點擊保存,即可啓動刷新重寫規則。

相關問題