Custom Post Type & Taxonomy permalinks
-
Hi,
I’ve a custom post type (galleries) and a custom taxonomy (gallery-category).
I want permalinks like this:
– custom post type page: http://www.mysite.com/category-title/post-title
– gallery category page: http://www.mysite.com/category-titleWhere:
– category-title = a term of “gallery-category” taxonomy
– post-title = a post of “galleries” post typeI did this:
/*------------------------------ Galleries permalinks ------------------------------*/ function galleries_permalinks( $post_link, $id = 0 ){ $post = get_post($id); if ( is_object( $post ) && $post->post_type == 'galleries' ){ $terms = wp_get_object_terms( $post->ID, 'gallery-category' ); if( $terms ){ return str_replace( '%gallery-category%' , $terms[0]->slug , $post_link ); } } return $post_link; } add_filter( 'post_type_link', 'galleries_permalinks', 1, 2 ); /*------------------------------ Galleries categories ------------------------------*/ function galleries_categories_permalinks( $url, $term, $taxonomy ){ return get_bloginfo('url').'/'.$term->slug; } add_filter( 'term_link', 'galleries_categories_permalinks', 10, 3 );It works very well for my custom posts type and my taxonomies, but the normal pages of the website are always 404 page.
I think it’s because of the taxonomy page who have the same structure of permalink now, so I think WordPress find a taxonomy and not a page.
So I don’t know how to do this.
Thank you for your help.
The topic ‘Custom Post Type & Taxonomy permalinks’ is closed to new replies.