title: Define permalinks for custom post type by taxonomy
body: <p>I want to create canonical permalinks for products and product types. I have the custom post types and custom taxonomy figured out, but I don't know if its possible to define permalinks with taxonomies. So my workflow, for example, would be this...</p>
  
  <ol>
  <li>I create a custom post type called <strong>products</strong>.</li>
  <li>Then I create a custom taxonomy for <strong>product types</strong>.</li>
  <li>Then I add a product type called <strong>'Chairs'</strong> and add a product called
  <strong>'Red Chair'</strong> to this category.</li>
  </ol>
  
  <p>Once I create this product, the <strong>desired permalink structure</strong> to view this product would be
      formatted like so -></p>
  
  <pre><code>http://shop.com/products/chairs/red-chair
  </code></pre>
  
  <p>Is this possible in wordpress 3.4? The meta boxes in my custom post type allow for selecting of the product types defined for my custom taxonomy, and there will only ever be one type per product.</p>
  
  <p>If possible, I would also like to include any parents of the selected product category if possible (For example, if the <strong>'chairs'</strong> category was a child of the <strong>'lounge'</strong> category, the permalink structure would be as follows -></p>
  
  <pre><code>http://shop.com/products/lounge/chairs/red-chair
  </code></pre>
  
  <p>Here is how I create the custom post type and the custom taxonomy, I just need help defining rewrite / slug rules to include product type in the permalink.</p>
  
  <pre><code>/* Custom Post Type - Products ------- */
  function products_init() {
      $args = array(
          'public' =&gt; true,
          'label' =&gt; 'Products'
      );
      register_post_type( 'products', $args );
  }
  add_action( 'init', 'products_init' );
  
  /* Custom Taxonomy - Product Type ------- */
  add_action( 'init', 'create_prodtype' );
  function create_prodtype() {
      $labels = array(
          'name' =&gt; _x( 'Product Type', 'products' ),
          'singular_name' =&gt; _x( 'Product Category', 'product' ),
          'search_items' =&gt;  __( 'Search Product Types' ),
          'all_items' =&gt; __( 'All Product Types' ),
          'parent_item' =&gt; __( 'Products' ),
          'parent_item_colon' =&gt; __( 'Products:' ),
          'edit_item' =&gt; __( 'Edit Product Type' ),
          'update_item' =&gt; __( 'Update Product Type' ),
          'add_new_item' =&gt; __( 'Add New Product Type' ),
          'new_item_name' =&gt; __( 'New Product Type' ),
      );
      register_taxonomy(
          'products',
          array('products'),
          array(
              'rewrite' =&gt; array(
                  'slug' =&gt; 'products',
                  'hierarchical' =&gt; true
              ), 
              'with_front' =&gt; false,
              'labels' =&gt; $labels
      ));
  }
  </code></pre>