So I am working on a WordPress-site and I needed to create a custom post type. I have the function setup to initialize it with WordPress
add_action( 'init', 'init_staff' );
function init_staff(){
register_post_type('staff_members',array(
"labels" => array(
"name" => "Staff Members",
"singular_name" => "Staff Member",
"menu_name" => "Staff Members",
"add_new" => "Add New",
"add_new_item" => "Add New Staff Member",
"edit" => "Edit",
"edit_item" => "Edit Staff Member",
"new_item" => "New Staff Member",
"view" => "View",
"view_item" => "View Staff Member",
"search_items" => "Search Staff Members",
"not_found" => "No Staff Member Found",
"not_found_in_trash" => "Staff Member Not Found in Trash"
),
"public" => true,
"supports" => array('title','editor','thumbnail'),
"has_archive" => true
));
}
I then created a file of single-staff_members.php with the WordPress loop in it and yet when ever I navigate to www.mysite.com/staff_members or www.mysite.com/staff_members/post_title I get the the page you are looking for doesn’t exist 404.
Here’s the single-staff_members.php file
<?php
get_header();
?>
<div id="leftcolumn">
<div class="main-content">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php endwhile; else: ?>
<p>Sorry, no posts found.<p></p>
<?php endif; ?>
</div>
</div>
<?php
get_footer();
?>
Refresh permalink structure (Settings->permalinks click save).