title: Wordpress get_template_part not working - returns 404 page instead of loop-xxx.php
body: <p>Usually I try my best to find answers by searching online or endless experimenting. This time I'm really desperate. I have read many related questions but none has the solution to my problem. </p>
  
  <p>I use 'get_template_part' in many other themes and it worked well. This time I don't know what made the difference.</p>
  
  <p>In my theme there is a registered custom post type <strong>event</strong>. The url of a post in event would  look like <em>example.com/event/wine-tasting</em>. </p>
  
  <p>The problem is: <em>example.com/event/</em> returns a 404 page instead of lining up all event posts (loop-event.php)</p>
  
  <p>Here is my archive.php:</p>
  
  <pre><code>&lt;?php get_header(); ?&gt;
  &lt;?php if ( have_posts() ) the_post();?&gt;
  &lt;?php rewind_posts();?&gt;
  &lt;?php $post_type = get_post_type();
      get_template_part( 'loop', $post_type );?&gt;
  &lt;?php get_footer(); ?&gt;
  </code></pre>
  
  <p>Here is my loop-event.php:</p>
  
  <pre><code>&lt;?php get_header(); ?&gt;
  &lt;?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?&gt;
      &lt;div class="container"&gt;
          &lt;?php the_title();?&gt;
          &lt;?php the_content();?&gt;
      &lt;/div&gt;
  &lt;?php endwhile; ?&gt;
  </code></pre>
  
  <p>This is how I register the custom post type 'event':</p>
  
  <pre><code>function yd_create_post_type_event() 
  {
  $labels = array(
      'name' =&gt; __( 'Events','yd'),
      'singular_name' =&gt; __( 'Event','yd' ),
      'add_new' =&gt; __('Add New','yd'),
      'add_new_item' =&gt; __('Add New Event','yd'),
      'edit_item' =&gt; __('Edit Event','yd'),
      'new_item' =&gt; __('New Event','yd'),
      'view_item' =&gt; __('View Event','yd'),
      'search_items' =&gt; __('Search Event','yd'),
      'not_found' =&gt;  __('No event found','yd'),
      'not_found_in_trash' =&gt; __('No event found in Trash','yd'), 
      'parent_item_colon' =&gt; ''
    );
  
    $args = array(
      'labels' =&gt; $labels,
      'public' =&gt; true,
      'exclude_from_search' =&gt; false,
      'publicly_queryable' =&gt; true,
      'show_ui' =&gt; true, 
      'show_in_menu' =&gt; true,
      'show_in_admin_bar' =&gt; true,
      'query_var' =&gt; true,
      'capability_type' =&gt; 'post',
      'hierarchical' =&gt; false,
      'menu_position' =&gt; 5,
      'menu_icon' =&gt; 0,
      'supports' =&gt; array('title','editor','excerpt')
  
    ); 
  
   register_post_type('event',$args);
  }
  
  register_taxonomy(
      "event-category", 
      array("event"), 
      array(
          "hierarchical" =&gt; true, 
          "label" =&gt; __( "Event Categories",'yd' ), 
          "singular_label" =&gt; __( "Event Category",'yd' ), 
          "rewrite" =&gt; array('slug' =&gt; 'event')
      )
  ); 
  </code></pre>
  
  <p>I would really appreciate your help. I have tried everything and I wish it was me who made some dumb mistakes. But I couldn't work it out so far. Thank you in advance!</p>