從拖網支持論壇和博客我看到除了我自己以外的公平的少數人在自定義帖子類型和永久鏈接上遇到困難。自定義的帖子類型返回404
我的自定義帖子類型(日記)註冊成功,並且管理端的所有內容都顯示正常。如果您在前端搜索它,它會顯示在搜索結果中。但是,當我點擊進入日記文章時,我收到了404。
我的代碼:
register_post_type('diary_post',
array(
'labels' => array(
'name' => __('Diary Post'),
'singular_name' => __('Diary Post'),
'add_new' => _x('Add New'),
'add_new_item' => __('Add New Diary Post'),
'edit_item' => __('Edit Diary Post'),
'new_item' => __('New Diary Post'),
'view_item' => __('View Diary Post'),
'search_items' => __('Search Diary Posts'),
'not_found' => __('No Diary posts found'),
'not_found_in_trash' => __('No Diary posts found in Trash'),
'parent_item_colon' => ''
),
'description' => __('Posts to appear on the Diary page'),
'public' => true,
'publicly_queryable' => false,
'exclude_from_search' => false,
'query_var' => true,
'menu_position' => 4,
'supports' => array('title','editor','author','excerpt','thumbnail', 'custom-fields','comments','trackbacks','revisions'),
'taxonomies' => array('diary_post_type','post_tag'),
'has_archive' => true,
'rewrite' => array('slug' => 'diary','with_front' => false)
)
);
我試圖從各個崗位下列建議的解決方案沒有任何成功:
- 節省再我的永久鏈接更改
- 「改寫」只是「真'
- 'with_front'=> false和
- 'with_front'=> true將
- flush_rewrite_rules();後
- register_post_type
- 檢查有沒有名爲「日記」
即使我嘗試通過默認的永久鏈接結構,如http://localhost/?diary_post=my-title-here我沒有成功訪問帖子頁或帖子。
該網站的我的永久鏈接結構目前是/%year%/%postname%
- 將其更改爲默認設置也無濟於事。
任何線索?在我的智慧結束在這裏。
有時,再次保存固定鏈接也可以解決問題。 – 2014-01-11 18:20:48