Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I would like know why my link : customposttype/parent-taxonomy/children-taxonomy redirect me to single post : customposttype/parent-taxonomy/single-post and not in the taxonomy-custom-taxomomy.php page...

That is my code :

//Set the names of the labels for the Post type interface
 $post_labels = array(
        'name' => 'Commerçants',
        'singular_name' => 'Commerçant',
        'add_new' => 'Ajouter un Commerçant',
        'add_new_item' => 'Ajouter un Commerçant',
        'edit_item' => 'Editer un Commerçant',
        'new_item' => 'Nouveau Commerçant',
        'view_item' => 'Afficher un Commerçant',
        'search_items' => 'Rechercher un Commerçant',
        'not_found' =>  'Aucun Commerçant',
        'not_found_in_trash' => 'Aucun Commerçant 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'=>'commercants-et-artisans/annuaire-des-commercants-et-artisans/%map_categories%','with_front'=>false), 'capability_type' => 'post', 'hierarchical' => true, 'supports' => array('title','editor' ), //specify what items the post type supports. 'has_archive' => false, 'menu_icon' => get_stylesheet_directory_uri() . '/bbw_framework/global/modules/map/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'=>'commercants-et-artisans/annuaire-des-commercants-et-artisans','with_front'=>false, 'hierarchical' => true) ) ); }

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 );

share|improve this question
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.