1

I have a custom taxonomy (editions) and would like to have a year / month hierarchy in the taxonomy reflected in the URL structure.

/editions/2016/december /editions/2017/december /editions/2018/december 

WordPress doesn't seem to allow me to create this on the admin side. Is this possible?

For reference, here is my custom taxonomy setup inside of my functions.php:

/* Editions Function */ function aa_editions_tax() { register_taxonomy( 'editions', 'page', array( 'labels' => array( 'add_new_item' => 'Add New Edition', 'all_items' => 'All Editions', 'edit_item' => 'Edit Edition', 'menu_name' => 'Editions', 'name' => 'Editions', 'new_item' => 'New Edition', 'not_found' => 'No Editions Found', 'not_found_in_trash' => 'No Editions Found in Trash', 'parent' => 'Parent of Edition', 'search_items' => 'Search Editions', 'singular_name' => 'Edition', 'view_item' => 'View Edition' ), 'hierarchical' => true, 'public' => true, 'rewrite' => array( 'hierarchical' => true ), 'query_var' => true, 'show_ui' => true )); } add_action( 'init', 'aa_editions_tax' ); 

1 Answer 1

1

EDIT

Since you can only have unique term slugs in a taxonomy, you should go for a "mixed taxonomy term" url setup.

You can check this, or this solution that involve creating your own add_rewrite_rules.

7
  • Thanks J. This is exactly what I did but when you create the identical children, December for example, WordPress will not give those children the same slug. They get slugs like december-2017 and december-2018, etc. Any idea how to get that to happen? Commented Aug 31, 2016 at 11:54
  • Another method is to just do a combination of month and year into the same top-level category 2016-January - it wouldn't be the end of the world. Commented Aug 31, 2016 at 11:55
  • true @staypuftman. in the same taxonomy you can only have unique slugs. you'll have to go for a mixed taxonomy-term, solution. Commented Aug 31, 2016 at 12:03
  • 1
    Thanks for the info - seems crazy you can't do this. Are we missing something in the codex? Commented Aug 31, 2016 at 13:36
  • 2
    Here in 2021, and can confirm that this still not possible. Commented Mar 17, 2021 at 12:46

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.