title: Registered post type not working
body: <p>I am trying to create a Custom post type in Wordpress and I'm actually stuck at this , because its not working and I don't know why.</p>
  
  <p>I copied the Custom post type code from here:  <a href="https://codex.wordpress.org/Post_Types#Custom_Post_Type_Templates" rel="nofollow">https://codex.wordpress.org/Post_Types#Custom_Post_Type_Templates</a></p>
  
  <p>And this is the code i added in my functions.php</p>
  
  <pre><code>add_action( 'init', 'create_posttype' );
  function create_posttype() {
  register_post_type( 'product',
          array( 
               'labels' =&gt; array(
                          'name' =&gt; __( 'Products' ),
                          'singular_name' =&gt; __( 'Product' )
                ),
               'public' =&gt; true,
               'capability_type' =&gt; 'post',
               'hierarchical' =&gt; false,
               'supports' =&gt; array('title', 'editor', 'thumbnail', 'comments', 'page-attributes'), 
               'has_archive' =&gt; true,
               'rewrite' =&gt; array('slug' =&gt; 'products'),
               )
         );
  }
  </code></pre>
  
  <p>and then i used this code below to create a new post:</p>
  
  <pre><code>// Create post object
  $my_post = array(
    'post_title'    =&gt; wp_strip_all_tags( $my_title ),
    'post_content'  =&gt; $my_content,
    'post_status'   =&gt; 'inherit',
    'post_author'   =&gt; 1,
    'post_type'   =&gt; 'product',
  );
  
  // Insert the post into the database
  wp_insert_post( $my_post );
  </code></pre>
  
  <p><strong>Then i tried to access it the link in the url, but i got a 404 page not found error !</strong></p>
  
  <p>Please any one know what i'm doing wrong?</p>