I have several custom post types, here is the creation of two of them:
Projects
add_action( 'init', 'register_cpt_project' );
function register_cpt_project() {
$labels = array(
'name' => _x( 'Projects', 'project' ),
'singular_name' => _x( 'Project', 'project' ),
'add_new' => _x( 'Add New', 'project' ),
'add_new_item' => _x( 'Add New Project', 'project' ),
'edit_item' => _x( 'Edit Project', 'project' ),
'new_item' => _x( 'New Project', 'project' ),
'view_item' => _x( 'View Project', 'project' ),
'search_items' => _x( 'Search Projects', 'project' ),
'not_found' => _x( 'No projects found', 'project' ),
'not_found_in_trash' => _x( 'No projects found in Trash', 'project' ),
'parent_item_colon' => _x( 'Parent Project:', 'project' ),
'menu_name' => _x( 'Projects', 'project' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'supports' => array( 'title', 'editor', 'excerpt' ),
'taxonomies' => array( 'project_categories' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => array('slug' => 'our-work/%project_categories%', 'with_front' => false),
'capability_type' => 'post'
);
register_post_type( 'project', $args );
}
Leadership
add_action( 'init', 'register_cpt_leadership' );
function register_cpt_leadership() {
$labels = array(
'name' => _x( 'Leaders', 'leadership' ),
'singular_name' => _x( 'Leadership', 'leadership' ),
'add_new' => _x( 'Add New', 'leadership' ),
'add_new_item' => _x( 'Add New Leadership', 'leadership' ),
'edit_item' => _x( 'Edit Leadership', 'leadership' ),
'new_item' => _x( 'New Leadership', 'leadership' ),
'view_item' => _x( 'View Leadership', 'leadership' ),
'search_items' => _x( 'Search Leaders', 'leadership' ),
'not_found' => _x( 'No leaders found', 'leadership' ),
'not_found_in_trash' => _x( 'No leaders found in Trash', 'leadership' ),
'parent_item_colon' => _x( 'Parent Leadership:', 'leadership' ),
'menu_name' => _x( 'Leaders', 'leadership' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'supports' => array( 'title', 'editor' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 20,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => false,
'query_var' => true,
'can_export' => true,
'rewrite' => array('slug' => 'who-we-are/leadership'),
'capability_type' => 'post'
);
register_post_type( 'leadership', $args );
}
Everything is working great on the public site, but when you log into the wp-admin section, that's where things get weird.
The Leadership post type functions correctly. But the Projects type, when using the pagination buttons in the list page, returns no posts when going to any page greater than 1.
So if I go to:
http://www.example.com/wp-admin/edit.php?post_type=project&paged=2
I get:
No projects found
Even though there are 70 posts, and the Screen Options are set to 20 posts per page. Yes, I can set that option to a higher number, and just show all posts in a single page, but that doesn't fix the problem at hand.
Has anyone had this issue before, or have any thoughts on how to fix this?
pre_get_posts
?