1

My custom taxonomy is linking to yearly archive instead of the post linked to it.

I have created a custom taxonomy named "year" containing int (i.e 2008,2009,2010 etc). Have registered the custom taxonomy using the following code.

// Add new "Years" taxonomy to Posts
register_taxonomy('year', 'post', array(
// Hierarchical taxonomy (like categories)
'hierarchical' => true,
// This array of options controls the labels displayed in the WordPress Admin UI
'labels' => array(
        'name' => _x( 'Year', 'taxonomy general name' ),
        'singular_name' => _x( 'Year', 'taxonomy singular name' ),
        'search_items' =>  __( 'Search Years' ),
        'all_items' => __( 'All Years' ),
        'parent_item' => __( 'Parent Year' ),
        'parent_item_colon' => __( 'Parent Year:' ),
        'edit_item' => __( 'Edit Year' ),
        'update_item' => __( 'Update Year' ),
        'add_new_item' => __( 'Add New Year' ),
        'new_item_name' => __( 'New Year Name' ),
        'menu_name' => __( 'Years' ),
    ),
    // Control the slugs used for this taxonomy
    'rewrite' => array(
        'slug' => 'Years', // This controls the base slug that will display before each term
        'with_front' => false, // Don't display the category base before "/Years/"
        'hierarchical' => true // This will allow URL's like "/Years/boston/cambridge/"
    ),
));

and echoed the year taxonomy under post using the following line.

<?php echo get_the_term_list( $post->ID, 'year', '<li>', '</li><li>', '</li>' ); ?>

I have registered two other taxonomies "player" and "team" in the same manner which are working perfectly.

Any help in this regard will be appreciated.

1

I would advise against the use of year as a post type or taxonomy name as its a reserved term and your rewrite rule may clash

For a list of reserved terms see here

Steps to take:

  • Modify the URL rewrite so it doesn't clash
  • Change the name of the taxonomy from year to something unique that isn't reserved
|improve this answer|||||

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.