title: Single Taxonomy Attached to Multiple Post Types Template Question
body: <p>So I have a site with about 6 custom post types.Three of these post types are attached to a single custom taxonomy.  </p>
  
  <p>I would like to be able to list_cats in the sidebar and spit out a url like <strong>../%post_type%/%taxonomy%/</strong> and have this take you to the <strong>taxonomy-%taxonomy%.php</strong> template and return only results of the <strong>%post_type%</strong>. </p>
  
  <p>I can create a conditional that will read the current <strong>%post_type%</strong> and style correctly once in the <strong>taxonomy-%taxonomy%.php</strong> file. I need some direction on the most effective method to modify the URL to pass the <strong>%post_type%</strong> to the query.</p>
  
  <p>Thanks in advance.  I have searched for a couple days with no clear answer.</p>
  
  <p><strong>So here are my feeble attempts at a solution yet they are one big FAIL</strong>
  This is based off a discussion found at <a href="http://www.rlmseo.com/blog/passing-get-query-string-parameters-in-wordpress-url/" rel="nofollow">rlmseo.com</a> ant the answer here.</p>
  
  <p><strong>Trying to add the post type to a variable to use in the Query:</strong></p>
  
  <p><em>practice-areas is a taxonomy.  Trying to add a variable that I can use to filter the taxonomy by post type in taxonomy-practice-areas.php</em></p>
  
  <pre><code>function add_query_vars($aVars) {
      $aVars[] = "cust_pt_var";    // represents the name of the custom post type as shown in the URL
      return $aVars;
  }
  
  // hook add_query_vars function into query_vars
  add_filter('query_vars', 'add_query_vars');      
  
  function add_rewrite_rules($aRules) {
      $aNewRules = array('practice-areas/([^/]+)/pt/([^/]+)/?$' =&gt; 'index.php?practice-areas=$matches[1]&amp;cust_pt_var=$matches[2]');
      $aRules = $aNewRules + $aRules;
      return $aRules;
  }
  
  // hook add_rewrite_rules function into rewrite_rules_array
  add_filter('rewrite_rules_array', 'add_rewrite_rules')
  </code></pre>
  
  <p><strong>Trying to pass query variables in the rewrite</strong></p>
  
  <p><em>Trying to add the post types (portfolio &amp; clients) as well as the practice-areas taxonomy term to the query at rewrite.</em></p>
  
  <pre><code>function add_rewrite_rules($aRules) {
      $aNewRules = array('portfolio/practice-areas/([^/]+)/?$' =&gt; 'index.php?post_type=portfolio&amp;practice-areas=$matches[1]');
      $aNewRules = array('clients/practice-areas/([^/]+)/?$' =&gt; 'index.php?post_type=clients&amp;practice-areas=$matches[1]');
      $aRules = $aNewRules + $aRules;
      return $aRules;
  }
  
  // hook add_rewrite_rules function into rewrite_rules_array
  add_filter('rewrite_rules_array', 'add_rewrite_rules')
  </code></pre>