Custom Post Type rewrite redirects to homepage

The most important args for rewrite redirects when registering new post type are:

  • ‘public’ => true,
  • ‘publicly_queryable’ => true,
  • ‘query_var’ => true,

I have pasted some code below which I have tested and it working fine for the url : www.example.com/people/john

$labels_employee = 
array('name' => _x( 'Employees', 'Post typegeneral name', 'textdomain' ),
'singular_name' => _x( 'Employee', 'Post type singular name', 'textdomain' ),
'menu_name' => _x( 'Employees', 'Admin Menu text', 'textdomain' ),
'name_admin_bar' => _x( 'Employee', 'Add New on Toolbar', 'textdomain' ),
'add_new' => __( 'Add New', 'textdomain' ),
'add_new_item' => __( 'Add New Employee', 'textdomain' ),
'new_item' => __( 'New Employee', 'textdomain' ),

$args_employee= array( 'labels' => $labels_employee, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'people' ), 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => null, 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ), );

register_post_type( 'employee', $args_employee );