Is there any way to add %post_type% and %taxonomy% to permalinks? I want to have links from one custom post type have one taxonomy's terms in its permalink, and another post type to use another taxonomy's terms.

  • Can you please be more specific? Update your question with the names of your current custom post types and custom taxonomies. And then tell us what type of Custom Permalink you are trying to set for them. Jun 20, 2011 at 4:48

1 Answer 1


I will try to answer the question in detailed but keeping it as short as possible considering you have achieved the basics. Suppose our custom post type one is to be connected to taxonomy one. Let's call them 'console'(custom post type) and 'brands'(taxonomy). You want to achieve: http://example.com/console/brands/sony/ Steps: Register the taxonomy first and attach it to custom post type console.

$labels = array(
    'name'                          => 'Brands',
    'singular_name'                 => 'Brand',
    'search_items'                  => 'Search Brands',
    'popular_items'                 => 'Popular Brands',
    'all_items'                     => 'All Brands',
    'parent_item'                   => 'Parent Brand',
    'edit_item'                     => 'Edit Brand',
    'update_item'                   => 'Update Brand',
    'add_new_item'                  => 'Add New Brand',
    'new_item_name'                 => 'New Brand',
    'separate_items_with_commas'    => 'Separate Brands with commas',
    'add_or_remove_items'           => 'Add or remove Brands',
    'choose_from_most_used'         => 'Choose from most used Brands'

$args = array(
    'label'                         => 'Brands',
    'labels'                        => $labels,
    'public'                        => true,
    'hierarchical'                  => true,
    'show_ui'                       => true,
    'show_in_nav_menus'             => true,
    'args'                          => array( 'orderby' => 'term_order' ),
    'rewrite'                       => array( 'slug' => 'consoles/brands', 'with_front' => false ),
    'query_var'                     => true

register_taxonomy( 'brands', 'consoles', $args );

Note here that the rewrite key in our $args array. That value is telling WordPress the slug to use in our Custom Taxonomy. We don’t want it prepended with the WordPress permalink front base, which defaults to true, and we want the slug to include our Custom Post Type rewrite slug.

Step Two: Now create the custom post type.I'm not writing the whole code but remember the important parameter here is the 'rewrite'

'rewrite'               => array( 'slug' => 'consoles', 'with_front' => false ),

visit your Settings > Permalinks options screen in the WordPress admin to ensure your new permalinks are picked up

Repeat the steps for second custom post type and taxonomy 2.:)cheers.. PS:You need to define has_archive key to have archive page.

  • Yes, I had made this more complicated than it was. An alternative way to frame my question would have been, "How do I insert the post_type (e.g., consoles) at the beginning of the permalink, before a custom taxonomy's terms. You answer solves that; the only thing this wouldn't work for is if you wanted to use the same taxonomy in more than one post type's permalinks. Like—in addition to /consoles/brands/sony (using CPT consoles), having /reviews/brands/sony (using CPT reviews).
    – supertrue
    Aug 23, 2011 at 20:06

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.