我注意到,設定"hierarchical" => true,使我的自定義帖子型別回傳404。我需要分層。
是否有其他的方法?
我試著通過設定->permalinks來重繪 我的permalinks,但它沒有起作用。
我還嘗試了flush_rewrite_rules(),但它也沒有起作用。
function create_hotel_post_type()
{
$labels = array(
'name' => _x('Hotels', 'post Type General Name', 'asdf')。
'singular_name' => _x('Hotel', 'Post Type Singular Name', 'asdf') 。
'menu_name' => __('Hotels', 'asdf') 。
'name_admin_bar' => __('Hotel', 'asdf') 。
'archives' => __('archives', 'asdf'),
'parent_item_colon' => __('Parent hotel', 'asdf') 。
'all_items' => __('所有酒店', 'asdf'),
'add_new_item' => __('Add New hotel', 'asdf') 。
'add_new' => __('Add New', 'asdf') 。
'new_item' => __('New Hotel', 'asdf') 。
'edit_item' => __('編輯酒店', 'asdf'),
'update_item' => __('Update hotel', 'asdf') 。
'view_item' => __('查看酒店', 'asdf'),
'search_items' => __('Search hotel', 'asdf') 。
'not_found' => __('not found', 'asdf') 。
'not_found_in_trash' => __('Not found in Trash', 'asdf') 。
'feature_image' => __('精選圖片', 'asdf'),
'set_featured_image' => __('Set featured image', 'asdf') 。
'remove_featured_image' => __('Remove featured image', 'asdf') 。
'use_featured_image' => __('Use as featured image', 'asdf') 。
'insert_into_item' => __('插入到酒店', 'asdf'),
'upload_to_this_item' => __('Uploaded to this hotel', 'asdf'),
'items_list' => __(' hotels list', 'asdf'),
'items_list_navigation' => __('hotel list navigation', 'asdf') 。
'filter_items_list' => __('過濾酒店串列', 'asdf') 。
);
$args = array(
'labs' => $labels,
'public' => true,
'public_queryable' => true。
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'capacity_type' => 'post'。
'has_archive' => true。
'hierarchical' => true,
'menu_position' => 1,
'supports' => ['title', 'thumbnail', 'page-attributes'] 。
'menu_icon' => 'dashicons-building',
'rewrite' => ['with_front' => false,] 。
);
register_post_type('hotel', $args) 。
}
uj5u.com熱心網友回復:
這與hierarchical引數沒有關系。
你只需要洗掉'rewrite'=>['with_front' => false,]引數。
如果你能讓它作業,請告訴我。
而子頁面:
uj5u.com熱心網友回復:
我通過禁用一個名為 "Polylang Slug "的插件解決了這個問題。似乎它與permalinks發生了沖突。
至于Ruvees的回答,頁面在
"true"和"false"鍵的布林值上都可以正常打開。轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/307830.html
標籤:




