我正在为帖子等设置“特殊”网址结构
我想要得到的结果是:sitename.com/club/justcavali 俱乐部是分类法的术语(club_type) 而justcavali是帖子类型(booking_type)
在我设置cpt改成%club_type%后,我的所有帖子/页面都转到404,并且我在这些页面上获得了一些废话查询,例如post_type =“ attachment”,
我已经尝试了每种方法来解决此问题,但是有人在分类法/ cpt中断或帖子/页面中断
当我插入“%club_type%”以重写cpt时,它中断了,是的,我禁用了“ with front”,而且我正在从术语中删除分类法基础
club_type / club-> / club
function cptui_register_my_cpts_listing() {
/**
* Post Type: Listing.
*/
$labels = array(
"name" => __( "Listing", "sage" ),
);
$args = array(
"label" => __( "Listing", "sage" ),
"labels" => $labels,
"description" => "New Listinga",
"public" => true,
"publicly_queryable" => true,
"show_ui" => true,
"delete_with_user" => false,
"show_in_rest" => true,
"rest_base" => "",
"rest_controller_class" => "WP_REST_Posts_Controller",
"has_archive" => true,
"show_in_menu" => true,
"show_in_nav_menus" => true,
"exclude_from_search" => false,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => true,
"rewrite" => array( "slug" => "/%club_type%/", "with_front" => false ),
"query_var" => true,
"supports" => array( "title", "editor" ),
"taxonomies" => array( "club_type", "city_part" ),
);
register_post_type( "listing", $args );
}
add_action( 'init', 'cptui_register_my_cpts_listing' );
function cptui_register_my_taxes_club_type() {
/**
* Taxonomy: Club Type
*/
$labels = array(
"name" => __( "club_type", "sage" ),
"singular_name" => __( "club_type", "sage" ),
);
$args = array(
"label" => __( "club_type", "bgn" ),
"labels" => $labels,
"public" => true,
"publicly_queryable" => true,
"hierarchical" => true,
"show_ui" => true,
"show_in_menu" => true,
"show_in_nav_menus" => true,
"query_var" => true,
"rewrite" => array( 'slug' => 'club_type', 'with_front' => false, ),
"show_admin_column" => true,
"show_in_rest" => true,
"rest_base" => "club_type",
"rest_controller_class" => "WP_REST_Terms_Controller",
"show_in_quick_edit" => true,
);
register_taxonomy( "club_type", array( "listing" ), $args );
}
add_action( 'init', 'cptui_register_my_taxes_club_type' );