That i would like (for taxonomy page):
当前URL:myurl。com/商业/工匠/布切里/
我尝试做什么URL:myurl。com/商业/工匠/食品/布切里/
营养是Boucherie的父母。
That i would like (for single page) :
当前URL:myurl。com/商业/工匠/食品/单件
我尝试做什么URL:myurl。com/商业/工匠/食品/布切里/singlepost
营养是Boucherie的父母。
谢谢你的帮助。
这是我的代码:
//This code tells WordPress when to run our setup function
add_action(\'after_setup_theme\', \'map\');
function map(){
//setup slider post type
//Set the names of the labels for the Post type interface
$post_labels = array(
\'name\' => \'Carte\',
\'singular_name\' => \'Carte\',
\'add_new\' => \'Ajouter un point carte\',
\'add_new_item\' => \'Ajouter un point carte\',
\'edit_item\' => \'Editer un point carte\',
\'new_item\' => \'Nouveau point carte\',
\'view_item\' => \'Afficher un point carte\',
\'search_items\' => \'Rechercher un point carte\',
\'not_found\' => \'Aucun point carte\',
\'not_found_in_trash\' => \'Aucun point carte trouvés dans la corbeille\',
\'parent_item_colon\' => \'\'
);
//Setup the rules for this post type. You can read more about what each of these do in
//the WP codex under register_post_type().
$post_args = array(
\'labels\' => $post_labels, //Add the labels that we set above
\'public\' => true,
\'publicly_queryable\' => true,//hide this post type from being accessed directly
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => array(\'slug\'=>\'commerce/artisans/%map_categories%\',\'with_front\'=>false),
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'supports\' => array(\'title\',\'editor\' ), //specify what items the post type supports.
\'has_archive\' => false,
\'menu_icon\' => get_stylesheet_directory_uri() . \'/map.png\',
);
//register the post type using the arguments we have setup above.
register_post_type(\'map\',$post_args);
register_taxonomy( \'map_categories\', \'map\', array( \'hierarchical\' => true, \'label\' => \'Catégories\', \'query_var\' => true, \'rewrite\' => array(\'slug\'=>\'commerce/artisans\',\'with_front\'=>false) ) );
}
function map_categories_link( $post_link, $id = 0 ){
$post = get_post($id);
if ( is_object( $post ) ){
$terms = wp_get_object_terms( $post->ID, \'map_categories\' );
if( $terms ){
return str_replace( \'%map_categories%\' , $terms[0]->slug , $post_link );
}
}
return $post_link;
}
add_filter( \'post_type_link\', \'map_categories_link\', 1, 3 );