title: Post Type & Taxonomy same slug issue
body: <p>I am working on a post_type and taxonomy. I create a page template "foo_template.php" for its main page, in main page I write a query that shows all taxonomies and related (5) Five posts. When i click on any taxonomy the new page open and it shows all post titles of clicked taxonomy and its slug is "foo_taxonomy", i also create for it a page "taxonomy-foo_post.php" and when i click any title it goes on single page which i created for it "single-foo_post.php" and its slug is "foo_post".</p>
  
  <p>Now the main issue is i want that post type and taxonomy slug is same when i do this my page layout is disturbed and it goes to archive.php</p>
  
  <p>My friend give me some code i write it, where post_type and taxonomy slug is same, when i click on the taxonomy the page open with new same slug but when i click on the post title for single page it shows that "Page not found"</p>
  
  <p>What is the issue i don't get it.</p>
  
  <p>Here is my code:</p>
  
  <p>Post type and Taxonomy code:</p>
  
  <pre><code>add_action('init', 'foo_articles');
  function foo_articles() {
      register_post_type('foo_knowledgebase', array(
          'labels' =&gt; array(
              'name' =&gt; 'Articles',
              'singular_name' =&gt; 'Article'
          ),
          'public' =&gt; true,
          'rewrite' =&gt; array(
              'slug' =&gt; 'My_slug')
      ));
  }
  
  add_action( 'init', 'foo_taxonomies', 0 );
  function foo_taxonomies() {
      register_taxonomy('foo_taxonomy', array('My_slug'), array(
          'labels' =&gt; array(
              'name' =&gt; 'Articles Category'
          ),
          'show_ui' =&gt; true,
          'show_admin_column' =&gt; true,
          'show_tagcloud' =&gt; FALSE,
          'hierarchical' =&gt; true,
          'rewrite' =&gt; array('slug' =&gt; 'My_slug', 'with_front' =&gt; TRUE)
      ));
  }
  </code></pre>
  
  <p>For same slug code:</p>
  
  <pre><code>$rules = array();
      $taxonomies = get_taxonomies(array('_builtin' =&gt; false), 'objects');
      $post_types = get_post_types(array('public' =&gt; true, '_builtin' =&gt; false), 'names');
  
      foreach ($post_types as $post_type) {
          $post_type_data = get_post_type_object( $post_type );
          $post_type_slug = $post_type_data-&gt;rewrite['slug'];
  
          foreach ($taxonomies as $taxonomy) {
              if ($taxonomy-&gt;object_type[0] == $post_type_slug) {
                      $categories = get_categories(array('type' =&gt; $post_type_slug, 'taxonomy' =&gt; $taxonomy-&gt;name, 'hide_empty' =&gt; 0));
                      /* @var $category type */
                      foreach ($categories as $category) {
                          $rules[$post_type_slug . '/' . $category-&gt;slug . '/?$'] = 'index.php?' . $category-&gt;taxonomy . '=' . $category-&gt;slug;
                      }
              }
          }
      }
      $wp_rewrite-&gt;rules = $rules + $wp_rewrite-&gt;rules;
  }
  add_filter( 'generate_rewrite_rules', 'taxonomy_slug_rewrite' );
  </code></pre>
  
  <p>My friend said that this code work for him but i dont now what happen here i copied same code.</p>
  
  <p>This condition is also set true</p>
  
  <pre><code>if ($taxonomy-&gt;object_type[0] == $post_type_slug)
  </code></pre>
  
  <p>but i don't know why my slug not work.</p>
  
  <p>Please help me</p>