I'm looking for a scalable, best-practice way to do the following:

I need a menu to have a link to the homepage, a standard page, and a variable number of custom post type archives. Each archive must also have one standard sub-page and a category page with all the posts with a specific custom taxonomy. So the menu would look like this:

 Artist 1 Archive
      About Artist 1
      Custom Taxonomy
 Artist 2 Archive
      About Artist 2
      Custom Taxonomy

And so on for all other artists.

Currently, I'm using WordPress's built-in archives for the custom post types, so they're not showing up in my menu--but I'm not adverse to just using a custom url (e.g., /artist-1/). What I'm having difficulty with is how to create the archives for the custom taxonomy. Is there a way I can set up a page template and somehow use get_query_var() to get the post type? Or is there a more natural way to do this?

Finally, I also have to redirect the URL; the custom taxonomy's category will be yes, but I need to change it to be accessed at portfolio.

Thanks very much for your help.

1 Answer 1


Maybe for the next time, create a question for each topic ;)

1) Menu Item for Custom Post Type archive

I don't have an automated solution here. But in my opionion it should be possible to create a similar widget inside the Menu Admin Page to display all Posttypes with an archive and generate a link to it which you than can drag&drop to your desired menu.

2) Post Template for Custom Taxonomy

If you display a term of a custom taxonomy, the default archive.php template is used. You could use some conditional statements to display content based on the taxonomy or the post type e.g. if(is_tax('YOUR_TAX') || is_post_type_archive('YOUR_POSTTYPE')). It should also be possible to use archive-{tax}.php for a static template file, but haven't tested it with the post type archives.

3) Permalink for Custom Taxonomy

During registration, you could set the rewrite parameter. So you could basically generate something like this:


To do this, you have to register your custom post type first with a special rewrite parameter. Than you register a new taxonomy object with register_taxonomy_for_object_type for your custom post type before you register your custom taxonomy. As described by Jan Fabry in a answer here on SE, this is necessary for the correct order of the generated rewrite rules.

Custom Post Type

$args = array(
    // your arguments
    'rewrite' => array('slug' => 'parent/cpt', 'with_front' => false)

register_post_type('YOUR_POSTTYPE', $args);
register_taxonomy_for_object_type('YOUR_TAXONOMY', 'YOUR_POSTTYPE');

Custom Taxonomy

$args = array(
   // your arguments
   'rewrite' => array('slug' => 'parent/cpt/taxonomy', 'with_front' => false)

register_taxonomy('YOUR_TAXONOMY', array(), $args);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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