title: custom post type redirects to home page in wordpress
body: <p><strong>I created this custom post type</strong></p>
  
  <pre><code> function my_custom_post_game() {
   $labels = array(
  'name'               =&gt; _x( 'Game', 'post type general name' ),
  'singular_name'      =&gt; _x( 'Games', 'post type singular name' ),
  'add_new'            =&gt; _x( 'Add New', 'Game' ),
  'add_new_item'       =&gt; __( 'Add New Game' ),
  'rewrite'            =&gt;array( 'slug' =&gt; 'game' ),
  'edit_item'          =&gt; __( 'Edit Game' ),
  'new_item'           =&gt; __( 'New Game' ),
  'all_items'          =&gt; __( 'All Games' ),
  'view_item'          =&gt; __( 'View Game' ),
  'search_items'       =&gt; __( 'Search Game' ),
  'not_found'          =&gt; __( 'No Games found' ),
  'not_found_in_trash' =&gt; __( 'No Games found in the Trash' ), 
  'parent_item_colon'  =&gt; '',
  'menu_name'          =&gt; 'Games'
  );
  $args = array(
  'labels'        =&gt; $labels,
  'description'   =&gt; 'Holds our Games and Game specific data',
  'public'        =&gt; true,
  'menu_position' =&gt; 5,
  'supports'      =&gt; array( 'title', 'editor', 'thumbnail','custom-fields',             'comments' ),
   'has_archive'   =&gt; true,
  );
  register_post_type( 'games', $args ); 
  }
  add_action( 'init', 'my_custom_post_game' );
  </code></pre>
  
  <p><strong>This is the loop on homepage</strong></p>
  
  <pre><code> $counter = 0;
        $args = array( 'post_type' =&gt; 'Game', 'posts_per_page' =&gt; 10 );
        $loop = new WP_Query( $args );
       while ( $loop-&gt;have_posts() ) : $loop-&gt;the_post();
       echo $post_id[rand(0,sizeof($post_id))];
       if($counter &lt; 2){
         ?&gt;
         &lt;a href=&lt;?php get_post_permalink()?&gt;&gt;
          &lt;div id="mypost" class="col-md-5" style="min-height:400px;"&gt;
          &lt;?php the_post_thumbnail('large');
           ?&gt;
          &lt;/div&gt;
          &lt;/a&gt;
          &lt;div class="col-md-1"&gt;&lt;/div&gt;
      &lt;?php
      $counter++;
       } 
      else {?&gt;
      &lt;a href=&lt;?php get_post_permalink()?&gt;&gt;
       &lt;div id="mypost" class="col-md-3" href=&lt;?php get_permalink()?&gt;&gt;
           &lt;!-- post display --&gt;  &lt;?php echo get_post_permalink()?&gt;
           &lt;?php the_post_thumbnail('medium'); ?&gt;
          &lt;/div&gt;
      &lt;/a&gt;
          &lt;div class="col-md-1"&gt;&lt;/div&gt;
         &lt;?php 
         }
       endwhile; ?&gt;
  </code></pre>
  
  <p>permalink gives 
      <a href="http://localhost/indigamer/?post_type=game&amp;p=63" rel="nofollow">http://localhost/indigamer/?post_type=game&amp;p=63</a></p>
  
  <p>but when I right-click on the div block and copy link location, it gives a link to homepage</p>
  
  <p>I have created single-game.php in my theme's root folder</p>
  
  <p>here is the code</p>
  
  <pre><code>&lt;?php get_header(); ?&gt;
  
  &lt;div id="primary" class="content-area"&gt;
  
      &lt;main id="main" class="site-main  site-main--single" role="main"&gt;
  
      test
  
      &lt;/main&gt;&lt;!-- #main --&gt;
  
  &lt;/div&gt;&lt;!-- #primary --&gt;
  </code></pre>