我有一个帖子类型/城市/。。假设我用slug toronto canada创建了一个名为toronto的城市。
现在我有/城市/多伦多加拿大/
是否有一种方法可以为自定义帖子类型中的每个帖子动态添加更多路径?
例如,当我发表多伦多邮报时,应该有一条路径,即:/城市/多伦多加拿大/商店和/城市/多伦多加拿大/要做的事情
几乎只是每个帖子/城市/加拿大多伦多/任何地方的定义url
// City Post Type & Taxonomy
function create_city_category_hierarchical_taxonomy() {
$labels = array(
\'name\' => _x( \'Categories\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Category\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Categories\' ),
\'all_items\' => __( \'All Categories\' ),
\'parent_item\' => __( \'Parent Category\' ),
\'parent_item_colon\' => __( \'Parent Category:\' ),
\'edit_item\' => __( \'Edit Category\' ),
\'update_item\' => __( \'Update Category\' ),
\'add_new_item\' => __( \'Add New Category\' ),
\'new_item_name\' => __( \'New Category Name\' ),
\'menu_name\' => __( \'Categories\' ),
);
register_taxonomy(\'city_category\',null, array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'cities\'),
));
}
function city_post_type() {
$labels = array(
\'name\' => _x( \'Cities\', \'post type general name\' ),
\'singular_name\' => _x( \'City\', \'post type singular name\' ),
\'add_new\' => _x( \'Add New\', \'book\' ),
\'add_new_item\' => __( \'Add New City\' ),
\'edit_item\' => __( \'Edit City\' ),
\'new_item\' => __( \'New City\' ),
\'all_items\' => __( \'All Cities\' ),
\'view_item\' => __( \'View Cities\' ),
\'search_items\' => __( \'Search Cities\' ),
\'not_found\' => __( \'No City found\' ),
\'not_found_in_trash\' => __( \'No Cities found in the Trash\' ),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Cities\'
);
$args = array(
\'labels\' => $labels,
\'description\' => \'Holds xxx Cities\',
\'public\' => true,
\'menu_position\' => 99999,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'page-attributes\',\'comments\' ),
\'taxonomies\' => array(\'city_category\'),
\'has_archive\' => true,
\'has_parent\' => true,
\'menu_icon\' => \'dashicons-building\',
\'hierarchical\' => true,
\'rewrite\' => array(\'slug\' => \'city\'),
);
register_post_type( \'city\', $args );
flush_rewrite_rules();
}
add_action( \'init\', \'create_city_category_hierarchical_taxonomy\', 0 );
add_action( \'init\', \'city_post_type\' );
谢谢!。