I made a custom post type and I’ve made a taxonomy registered to the cpt and the standard ‘post’. This all works perfect.
Now I needed a 2nd taxonomy for organization reasons. I’ve simply copied the first one and changed the name and labels.
On the backend it all works normal, but on the front end clicking on it redirects to index.php. If I look via the debug toolbar at the query it is attachment=(term-name) instead of (taxonomy)=(term-name). Does anybody have any idea why wordpress does this? (Or to put it better, how did I make wordpress do this?)
This is how the taxonomies are registered, ‘arweb’ is the cpt and ‘onderwerp’ is the normal working taxonomy:
add_action( 'init', 'register_custom_taxonomies' );
function register_custom_taxonomies(){
// ///////////////////// ONDERWERP //////////////////////
$labels = array(
'name' => _x( 'Onderwerpen', 'taxonomy general name' ),
'singular_name' => _x( 'Onderwerp', 'taxonomy singular name' ),
'search_items' => __( 'Zoek Onderwerpen' ),
'popular_items' => __( 'Popular Onderwerpen' ),
'all_items' => __( 'All Onderwerpen' ),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __( 'Edit Onderwerp' ),
'update_item' => __( 'Update Onderwerp' ),
'add_new_item' => __( 'Nieuw Onderwerp' ),
'new_item_name' => __( 'Naam Nieuw Onderwerp' ),
'add_or_remove_items' => __( 'Add or remove onderwerpen' ),
'choose_from_most_used' => __( 'Choose from the most used onderwerps' ),
'not_found' => __( 'No onderwerps found.' ),
'menu_name' => __( 'Onderwerpen' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'onderwerp' ),
);
register_taxonomy( 'onderwerp', array( "arweb","post" ), $args );
register_taxonomy_for_object_type( 'onderwerp', 'arweb' );
///////////////////// English onderwerp /////////////////////////////////////////////
$labels = array(
'name' => _x( 'Subjects', 'taxonomy general name' ),
'singular_name' => _x( 'Subject', 'taxonomy singular name' ),
'search_items' => __( 'Zoek Subjects' ),
'popular_items' => __( 'Popular Subjects' ),
'all_items' => __( 'All Subjecten' ),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __( 'Edit Subject' ),
'update_item' => __( 'Update Subject' ),
'add_new_item' => __( 'Nieuw Subject' ),
'new_item_name' => __( 'Naam Nieuw Subject' ),
'add_or_remove_items' => __( 'Add or remove onderwerpen' ),
'choose_from_most_used' => __( 'Choose from the most used onderwerps' ),
'not_found' => __( 'No onderwerps found.' ),
'menu_name' => __( 'Subjecten' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
//'update_count_callback' => '_update_post_term_count',
'query_var' => true,
//'rewrite' => array( 'slug' => 'english-subject' ),
);
register_taxonomy( 'onderwerp_en', array( "arweb","post" ), $args );
register_taxonomy_for_object_type( 'onderwerp_en', 'post' );
register_taxonomy_for_object_type( 'onderwerp_en', 'arweb' );
}
Try updating your permalinks (by going to Settings .. Permalinks and saving). It’s possible the URL is matching an outdated rewrite rule.