JGinDC
JGinDC

Reputation: 91

Custom Post Type posts not listing in Dashboard

I'm trying to set up a custom post type "staff" in WordPress (something I've done numerous times in the past on other sites), but when I try to view the edit.php listing for the custom post type in the WordPress dashboard, the posts shown in the listing are the ones using built-in post type "post," rather than post type "staff."

In other words, [MyWordPressSite]/wp-admin/edit.php?post_type=staff shows the posts with post_type='post', rather than the posts with post_type='staff'. The numbers in parentheses next to All and Published are the correct number of post_type='staff' posts, but obviously don't match the listed posts.

Screenshot

Here's the code I'm using for register_post_type:

add_action( 'init', 'staff_init' );
function staff_init() {
    $labels = array(
        'name'               => 'Staff' ,
        'singular_name'      => 'Staff Member' ,
        'menu_name'          => 'Staff' ,
        'name_admin_bar'     => 'Staff' ,
        'add_new'            => 'Add New Staff' ,
        'add_new_item'       => 'Add New Staff Member' ,
        'new_item'           => 'New Staff Member' ,
        'edit_item'          => 'Edit Staff Member' ,
        'view_item'          => 'View Staff Member' ,
        'all_items'          => 'All Staff Members' ,
        'search_items'       => 'Search Staff Members' ,
        'not_found'          => 'No staff members found.' ,
        'not_found_in_trash' => 'No staff members found in trash.'
    );

    $args = array(
        'labels'             => $labels,
        'description'        => 'Staff Members' ,
        'public'             => true,
        'publicly_queryable' => true,
        'show_ui'            => true,
        'show_in_menu'       => true,
        'query_var'          => true,
        'capability_type'    => 'post',
        'has_archive'        => true,
        'hierarchical'       => false,
        'menu_position'      => null,
        'supports'           => array( 'title', 'editor', 'thumbnail', 'excerpt' )
    );

    register_post_type( 'staff', $args );
}

I've tried disabling every plugin on the site, running flush_rewrite_rules() (several times), and changing the name of the post type to something I was 1000% certain wasn't being used anywhere else, but nothing seems to help.

Upvotes: 1

Views: 971

Answers (1)

JGinDC
JGinDC

Reputation: 91

Problem solved. Deep in my functions.php there was a function that was using set_query_var to reset the post_type variable to 'post' (so that staff members wouldn't be included in archive pages), but didn't have an is_admin() test.

Upvotes: 3

Related Questions