我感觉接近完成了这个。总之,我似乎无法展示帖子。 例如,我有:
http://somedomain.org/tours //Displays all categories
http://somedomain.org/tours/gbr //Displays all posts in category
http://somedomain.org/tours/gbr/my-post //Should display post in category
http://somedomain.org/tours/gbr/my-post
没有显示,我在这里找不到任何内容,404错误。但是,如果我去:
http://somedomain.org/toursgbr/my-post
事实上,显示帖子(如果你正在寻找差异,“toursgbr”没有正斜杠)
我正在使用最新的WordPress。我正在使用插件: 自定义帖子类型永久链接
我在functions.php文件中有以下代码:
// Our custom post type function
function create_posttype() {
register_post_type( 'tours',
// CPT Options
array(
'labels' => array(
'name' => __( 'Tours' ),
'singular_name' => __( 'Tour' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'tours', 'with_front' => TRUE),
'cptp_permalink_structure' => '%tour_category%/%postname%',
'hierarchical' => true //A added
)
);
}
// Hooking up our function to theme setup
add_action( 'init', 'create_posttype' );
function my_taxonomies_tours() {
$labels = array(
'name' => _x( 'Tour Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Tour Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Tour Categories' ),
'all_items' => __( 'All Tour Categories' ),
'parent_item' => __( 'Parent Tour Category' ),
'parent_item_colon' => __( 'Parent Tour Category:' ),
'edit_item' => __( 'Edit Tour Category' ),
'update_item' => __( 'Update Tour Category' ),
'add_new_item' => __( 'Add New Tour Category' ),
'new_item_name' => __( 'New Tour Category' ),
'menu_name' => __( 'Tour Categories' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'rewrite' => array('slug' => 'tours')
);
register_taxonomy( 'tour_category', 'tours', $args );
}
add_action( 'init', 'my_taxonomies_tours', 0 );
代码行:
'cptp_permalink_structure' => '%tour_category%/%postname%',
如果我添加正斜杠,那就是:
'cptp_permalink_structure' => '/%tour_category%/%postname%',
那是我无法查看帖子的时候。任何正确方向的帮助都会很棒。除了gbr之外我还有其他类别,帖子可以有多个类别。我认为这可能是重要的信息