我有自定义的帖子类型venue
以及自定义分类法“设施”和“类型”,可以使用当前的posts分类法slug为单个post和归档生成自定义永久链接。示例:
单岗位任期
facility
slug是“餐厅”
http://mywebsite.com/restaurant/restaurant-name
存档页面
http://mywebsite.com/restaurants
我的自定义帖子声明
$args = array(
\'label\' => __( \'Venue\', \'weera\' ),
\'description\' => __( \'Dubai day Venue listings\', \'weera\' ),
\'labels\' => $labels,
\'supports\' => array( \'title\', \'excerpt\', \'author\', \'thumbnail\', \'revisions\'),
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'menu_position\' => 5,
\'menu_icon\' => \'dashicons-palmtree\',
\'show_in_admin_bar\' => true,
\'show_in_nav_menus\' => true,
\'can_export\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'page\',
\'rewrite\' => array( \'slug\' => \'restaurant\'),
\'has_archive\' => true,
);
register_post_type( \'venue\', $args );
我的分类“设施”声明
$args = array(
\'labels\' => $labels,
\'hierarchical\' => true,
\'public\' => true,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'show_in_nav_menus\' => true,
\'show_tagcloud\' => true,
\'rewrite\' => array( \'slug\' => \'venue\' ),
);
register_taxonomy( \'facility\', array( \'venue\' ), $args );
但是
http://mywebsite.com/restaurants 和
http://mywebsite.com/restaurant/restaurant-name 两者都有404页。