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.

Possible Duplicate:
Semantic URL Custom Post Type and Taxonomies permalinks

I created custom taxonomy.

And my urls/permaliniks at the moment look like this: custom-post-type/post-name

I want it to look like: custom-post-type/custom-taxonomy-parent/custom-taxonomy-child/post-name

btw. same problem is present with categories. I don't see any hierarchy!

Is this possible? if yes can you please forward me to the right documentation in codex? I'm searching for an hour cannot find anything to solve this problem!

ty.

//Create custom post type Other Cities
add_action( 'init', 'create_post_type_othercities' );
function create_post_type_othercities() {
    register_post_type( 'other-cities',
        array(
            'labels' => array(
                'name' => __( 'Other Cities' ),
                'singular_name' => __( 'City' )
            ),
        'public' => true,
        'has_archive' => true,
        'capability_type' => 'post',
        'publicly_queryable' => true,
        'hierarchical' => false,
        'show_ui' => true,
        'supports' => array("title", "editor", "thumbnail", "author", "custom-fields", "excerpt", "comments")
        )
    );
}
//Create taxonomy(category) for Other cities
register_taxonomy("other-cities", array("other-cities"), array("hierarchical" => true, "label" => "Cities", "singular_label" => "City", "rewrite" => true));

edit. I noticed I have same url for other-cities slug for taxonomy and custom post types. This is definitely causing 404 errors.

share|improve this question

marked as duplicate by Brian Fegter, kaiser, Chris_O, anu, mrwweb Oct 6 '12 at 15:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
@BrianFegter Duplicate or not, that question has not been answered either. –  Sandro Dzneladze Sep 2 '12 at 10:53
    
Please read wordpress.stackexchange.com/faq#close You will notice that duplicate questions are closed. There's not a good reason to have two threads along the same path. Have you looked at the answer on the other post? You will find what you're looking for there. –  Brian Fegter Sep 2 '12 at 17:39
    
@BrianFegter Answer is not helping me in any way. –  Sandro Dzneladze Sep 2 '12 at 19:46
    
@SandroDzneladze On the one hand, that doesn't mean that it's ok to just open another question. If you improve yours and make it different enough, than it's ok. On the other hand, "is not helping me in any way" is no proper problem or error description. How should anyone help you with no information about the why etc.? –  kaiser Sep 21 '12 at 16:33

1 Answer 1

Add this just below your support (or anywhere inside register_post_type array ) 'taxonomies' => array('category', 'post_tag').

And for 404 error, you miss to add flush_rewrite_rules(); So your final code should look like this

/**

add_action( 'init', 'create_post_type_othercities' );
function create_post_type_othercities() {
    register_post_type( 'other-cities',
        array(
            'labels' => array(
                'name' => __( 'Other Cities' ),
                'singular_name' => __( 'City' )
            ),
        'public' => true,
        'has_archive' => true,
        'capability_type' => 'post',
        'publicly_queryable' => true,
        'hierarchical' => true,
        'show_ui' => true,
        'supports' => array("title", "editor", "thumbnail", "author", "custom-fields", "excerpt", "comments"),
        'taxonomies' => array('category', 'post_tag')
        )
    );
    flush_rewrite_rules();
}
//Create taxonomy(category) for Other cities
register_taxonomy("other-cities", array("other-cities"), array("hierarchical" => true, "label" => "Cities", "singular_label" => "City", "rewrite" => true));
**/
share|improve this answer
1  
Down-voting as this is a bad practice. Directly from the codex: Important: Flushing the rewrite rules is an expensive operation, there are tutorials and examples that suggest executing it on the 'init' hook. This is bad practice. –  Brian Fegter Sep 14 '12 at 13:38
    
Alternatively, simply visiting the Settings->Permalinks page will flush the rewrite rules. –  Brian Fegter Sep 14 '12 at 14:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.