title: Wordpress custom post type not showing in category template
body: <p>I'm encountering some strange issue when trying to display the list of custom post type in a category template. I have a category-<em>spettacoli</em>.php template that is supposed to list all <em>spettacoli</em> custom posts of a given category, but no result is being shown at all. </p>
  
  <p>This is even stranger since I have another custom post type called <em>corsi</em> that is working perfectly (category template etc.) although the two custom post types category templates are almost identical.</p>
  
  <p>Here's the code:</p>
  
  <p><strong>functions.php (custom post types and category creation part)</strong></p>
  
  <pre><code>add_action( 'init', 'create_post_type' );
  
  //add custom post types
  function create_post_type() {
      register_post_type( 'corsi',
          array(
              'labels' =&gt; array(
                  'name' =&gt; __( 'Corsi' ),
                  'singular_name' =&gt; __( 'Corso' )
              ),
          'public' =&gt; true,
          'has_archive' =&gt; true,
          'menu_position' =&gt; 20,
          'taxonomies' =&gt; array('category'), 
          'supports' =&gt; array('title', 'editor', 'thumbnail'),
          )
      );
      register_post_type( 'spettacoli',
          array(
              'labels' =&gt; array(
                  'name' =&gt; __( 'Spettacoli' ),
                  'singular_name' =&gt; __( 'Spettacolo' )
              ),
          'public' =&gt; true,
          'has_archive' =&gt; true,
          'menu_position' =&gt; 20,
          'taxonomies' =&gt; array('category'), 
          'supports' =&gt; array('title', 'editor', 'thumbnail'),
          )
      );
      flush_rewrite_rules();
  }
  
  // add custom post to category filter
  function namespace_add_custom_types_spettacoli( $query ) {
      if( is_category() || is_tag() &amp;&amp; empty( $query-&gt;query_vars['suppress_filters'] ) ) {
          $query-&gt;set( 'post_type', array(
              'post', 'spettacoli'
          ));
          return $query;
      }
  }
  add_filter( 'pre_get_posts', 'namespace_add_custom_types_spettacoli' );
  
  function namespace_add_custom_types_corsi( $query ) {
      if( is_category() || is_tag() &amp;&amp; empty( $query-&gt;query_vars['suppress_filters'] ) ) {
          $query-&gt;set( 'post_type', array(
              'post', 'corsi'
          ));
          return $query;
      }
  }
  add_filter( 'pre_get_posts', 'namespace_add_custom_types_corsi' );
  </code></pre>
  
  <p><strong>category-spettacoli.php (not working)</strong></p>
  
  <pre><code>&lt;?php 
  /*
   *  Spettacoli base archive template
   */
  get_header(); ?&gt;
  
  &lt;?php
      $cat_name = get_category(get_query_var('cat'))-&gt;name;
  ?&gt;
  
  &lt;h1&gt;&lt;?php echo $cat_name; ?&gt;&lt;/h1&gt;
  
  &lt;?php
     if ( have_posts() ) {
         while ( have_posts() ) {
              the_post(); 
              the_title();
              the_content();
         }
     }
  ?&gt;
  
  &lt;?php get_footer(); ?&gt;
  </code></pre>
  
  <p><strong>category-corsi.php (working)</strong></p>
  
  <pre><code>&lt;?php 
  /*
   *  Corsi base archive template
   */
  get_header(); ?&gt;
  
  &lt;?php
      $cat_name = get_category(get_query_var('cat'))-&gt;name;
  ?&gt;
  
  &lt;h1&gt;&lt;?php echo $cat_name; ?&gt;&lt;/h1&gt;
  
  &lt;?php
      if ( have_posts() ) {
          while ( have_posts() ) {
              the_post(); 
              the_title();
              the_content();
          }
      }
  ?&gt;
  
  &lt;?php get_footer(); ?&gt;
  </code></pre>
  
  <p>Categories have been created correctly and assigned correctly to all custom post types, so I'm guessing that is not the problem. 
  Also no permalink refresh is solving anything..</p>
  
  <p>Any help would be appreciated, thank you!</p>