请帮忙,我几乎什么都试过了,我完全迷路了!
我非常渴望建立以下permalink结构:
ladsholidayguide。com/custom\\u post/taxonomy/term/postname
例如:ladsholidayguide。com/评论/场馆/俱乐部/流动夜总会
我尝试过使用自定义的Post-Type Permalinks插件,但是这个选项也不起作用
选中此项,自定义分类法的永久链接将为:www.ladsholidayguide。com/post\\u type/taxonomy/term/postname/
出于某种原因
这很好用。ladsholidayguide。com/评论/场馆/伦敦垃圾场高尔夫/
这不是(我得到404)ladsholidayguide。com/评论/场馆/餐厅/imads叙利亚厨房/
似乎术语/子类别打破了它。
下面是使用的代码:如果有人知道如何修复此问题,请告诉我。
/** Custom Post Type Post Type: Reviews: **/
function cptui_register_my_cpts_reviews() {
$labels = array(
"name" => __( \'Reviews\', \'\' ),
"singular_name" => __( \'Review\', \'\' ),
);
$args = array(
"label" => __( \'Reviews\', \'\' ),
"labels" => $labels,
"description" => "",
"public" => true,
"publicly_queryable" => true,
"show_ui" => true,
"show_in_rest" => false,
"rest_base" => "",
"has_archive" => true,
"show_in_menu" => true,
"exclude_from_search" => false,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => true,
"rewrite" => array( "slug" => "reviews", "with_front" => false ),
"query_var" => true,
"supports" => array( "title", "editor", "thumbnail" ),
"taxonomies" => array( "review" ),
);
register_post_type( "reviews", $args );
}
add_action( \'init\', \'cptui_register_my_cpts_reviews\' );
/** Taxonomy: Review (not reviews due to custom post type name). **/
function cptui_register_my_taxes_review() {
$labels = array(
"name" => __( \'Review\', \'\' ),
"singular_name" => __( \'review\', \'\' ),
);
$args = array(
"label" => __( \'Review\', \'\' ),
"labels" => $labels,
"public" => true,
"hierarchical" => true,
"label" => "Review",
"show_ui" => true,
"show_in_menu" => true,
"show_in_nav_menus" => true,
"query_var" => true,
"rewrite" => array( \'slug\' => \'review\', \'with_front\' => true, \'hierarchical\' => true, ),
"show_admin_column" => false,
"show_in_rest" => false,
"rest_base" => "",
"show_in_quick_edit" => false,
);
register_taxonomy( "review", array( "reviews" ), $args );
}
add_action( \'init\', \'cptui_register_my_taxes_review\' );