2

I desperately need your help guys. I am trying to register custom post type and taxonomy the following way:

add_action( 'init', 'product_catalog' );
add_action( 'init', 'product_type', 0 );

function product_catalog() {
    $labels = array(
        'name'               => _x( 'Catalog', 'post type general name' ),       
        'menu_name'          => 'Catalog'
    );
    $args = array(
        'labels'        => $labels,
        'description'   => 'Catalog',
        'public'        => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,       
        'capability_type' => 'post',
        'hierarchical' => false,       
        'menu_position' => 5,
        'supports'      => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
        'has_archive'   => true,
        "rewrite" => array(       
            'with_front' => false,                       
            'slug' => 'catalog'           
        )
    );
    register_post_type( 'product_catalog', $args );

}


//taxonomy that wont work with first parent, all childs work just fine.

function product_type(){

    register_taxonomy("product_type", array("product_catalog"), array(
    "hierarchical" => true,
    "label" => "Types",
    "singular_label" => "Type",
    "show_ui" => true,       
    'show_admin_column' => true,
    'query_var' => true,
    "rewrite" => array(       
        'slug' => 'type',           
        'with_front' => false,
        "hierarchical" => true
        )
    ));   


}

It seems to show in the panel and I can add hierarchical taxonomies under the TYPE but the problem comes if I try to go to url like: sitename.com/type/parent it always returns 404 not found. At the same time I can go to childs of TYPE and it loads just fine like: sitename.com/type/parent/child

If I change the 'slug' => 'type' to anything else like: 'types' then it works 100%.

I don't get it, why this is happening, is it reserved for something?

I would appreciate your help.

Thank you.

4

It's not working because "type" is reserved for post format archive pages, i.e. http://example.com/type/video.

0

I can't quite wrap my head around this without being able to use the code myself, but I have had issues like this. In my experience, it's been a clash of a taxonomy/page title/taxonomy/term that cause rewrite issues/404's etc. You could flush your permalinks and revisit the pages, but the what you said about "Type" and "types" makes me think this is a conflict.

  • Thank you for getting back to me. I thought that it could be a conflict but I made a clean Wordpress install as well as clean DB meaning its 100% default with no terms, posts etc. created yet. That is what makes me think that the slug 'type' is reserved for some reason as parent term although it does work for children. – Alex Aug 23 '13 at 16:30
  • Don't see why - it would have to be a category name, or a tag, or a page name as far as I know. I don't spend much time with the default install, but I don't recall "type" being used in the URL structure anywhere. When you go to the taxonomy archive for your custom taxonomy "type", what do you get? (Just www.domain.com/taxonomy) – Dan Aug 23 '13 at 16:40
  • That is exactly the problem that If I go to my 'type' taxonomy like you say: www.domain.com/type I end up with 404 page. – Alex Aug 23 '13 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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