我有几种自定义帖子类型,下面是其中两种类型的创建:
项目
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 );
}
领导力
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 );
}
在公共网站上一切都很好,但当你登录到wp管理部分时,事情就变得很奇怪了。
领导岗位类型功能正常。但是,当使用列表页面中的分页按钮时,项目类型在转到任何大于1的页面时不会返回任何帖子。
所以如果我去:http://www.example.com/wp-admin/edit.php?post_type=project&paged=2
我得到:
找不到项目
即使有70篇文章,并且屏幕选项设置为每页20篇文章。是的,我可以将该选项设置为一个更大的数字,并在一个页面中显示所有帖子,但这并不能解决当前的问题。
以前有没有人遇到过这个问题,或者有没有想过如何解决这个问题?