我已经为视频创建了自定义帖子类型。这是我的密码。
function video_register() {
$labels = array(
\'name\' => _x(\'Video\', \'post type general name\'),
\'singular_name\' => _x(\'Video\', \'post type singular name\'),
\'add_new\' => _x(\'Add New\', \'video\'),
\'add_new_item\' => __(\'Add New Video\'),
\'edit_item\' => __(\'Edit Video\'),
\'new_item\' => __(\'New Video\'),
\'view_item\' => __(\'View Video\'),
\'search_items\' => __(\'Search Videos\'),
\'not_found\' => __(\'Nothing found\'),
\'not_found_in_trash\' => __(\'Nothing found in Trash\'),
\'parent_item_colon\' => \'\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'menu_icon\' => null,
\'rewrite\' => true,
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'menu_position\' => null,
\'supports\' => array(\'title\', \'editor\', \'thumbnail\', \'comments\', \'custom-fields\')
);
register_post_type(\'video\', $args);
}
我用这个代码在主页上显示了这个视频帖子。
$paged = (get_query_var(\'page\')) ? get_query_var(\'page\') : 1;
$temp = $wp_query;
$wp_query= null;
$vcount = 20;
$wp_query = new WP_Query();
$wp_query->query(\'posts_per_page=\'.$vcount.\'&post_type=video&paged=\'.$paged);
一切正常。但当我点击/page/2时,它的分页给了我404个错误。
此分页仅显示在主页上。在分类页面上,它运行良好。我不明白我弄错了什么。我在互联网上到处搜索,但找不到任何解决方案。请告诉我我的代码有什么问题。