What can make the custom post type template not display?

So I am working on a WordPress site and I need to create my own post type. I have a function 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
 ));    

      

}

Then I created a single-staff_members.php file with a WordPress loop, but when I go to www.mysite.com/staff_members or www.mysite.com/staff_members/post_title, I get the page you're looking for does not 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();
?>

      

+3


source to share


1 answer


Update permalink (Settings-> permalinks click save).



+10


source







All Articles