Taxonomies and Custom Permalink Structures
-
I use WordPress as both a CMS and a blogging platform. I have our company website set up so that all pages appear under the root, e.g. http://www.inspiresport.com/our-sports/ and http://www.inspiresport.com/getting-started/, while all posts appear under the /news/ subdirectory, e.g. http://www.inspiresport.com/news/2012/07/article-title/
I’ve done this by setting a custom permalink structure of /news/%year%/%monthnum%/%postname%/ on the Permalink Settings page.
The problem is, I’m now trying to use custom taxonomies for my pages, so I can categorise pages under destination and sport. I have set up two taxonomies, and below is the code for the ‘sport’ taxonomy.
register_taxonomy ( 'sport', 'page', array( 'hierarchical' => true, 'label' => 'Sport', 'query_var' => true, 'rewrite' => true, ) );The destination taxonomy is identical other than ‘sport’ being swapped for ‘destination’.
Now, because of the custom permalink structure used to ensure posts remain under the /news/ subdirectory, all of my taxonomies are also appearing under the ‘news’ directory.
So the index page for a taxonomy called Africa is showing up at http://www.inspiresport.com/news/destination/africa, rather than the ideal location of http://www.inspiresport.com/destination/africa
Removing the custom permalink structure fixes this, but of course all post urls revert to http://www.inspiresport.com/2012/07/article-title/
I have tried setting a custom slug, and setting with_front to false:
'rewrite' => array('slug' => 'destination', 'with_front' => 'false')but this doesn’t change anything, even after flushing the permalink structure. Is it possible for taxonomies to play nice while a custom permalink structure is set?
The topic ‘Taxonomies and Custom Permalink Structures’ is closed to new replies.