我有一个名为scents\\u list的自定义帖子类型和一个名为scents\\u category的自定义分类法。
我的目标是拥有像domain这样的页面。com/剧集/第一季。这非常有效,如果我有一个名为taxonomy-scents\\u category的模板的话。php和某人进入域。com/剧集/第一季,使用标准WordPress循环,它运行良好,并显示了第一季的所有剧集。
然而,当我尝试将分页添加到此页面时,当有人转到第2页时,url将更改为“域”。com/剧集/第一季/第页/第2页,返回404。我不知道如何让分页工作。
标准循环结束后的分页代码,同时:
next_posts_link( \'Older posts\' );
previous_posts_link( \'Newer posts\' );
我的自定义帖子类型/分类代码如下。
// Register Custom Post Type
function episodes() {
$labels = array(
\'name\' => _x( \'Episodes\', \'Post Type General Name\', \'text_domain\' ),
\'singular_name\' => _x( \'Episodes\', \'Post Type Singular Name\', \'text_domain\' ),
\'menu_name\' => __( \'Episodes\', \'text_domain\' ),
\'parent_item_colon\' => __( \'Parent Item:\', \'text_domain\' ),
\'all_items\' => __( \'All Episodes\', \'text_domain\' ),
\'view_item\' => __( \'View Item\', \'text_domain\' ),
\'add_new_item\' => __( \'Add New Episode\', \'text_domain\' ),
\'add_new\' => __( \'Add New Episode\', \'text_domain\' ),
\'edit_item\' => __( \'Edit Item\', \'text_domain\' ),
\'update_item\' => __( \'Update Item\', \'text_domain\' ),
\'search_items\' => __( \'Search Item\', \'text_domain\' ),
\'not_found\' => __( \'Not found\', \'text_domain\' ),
\'not_found_in_trash\' => __( \'Not found in Trash\', \'text_domain\' )
);
$rewrite = array(
\'slug\' => \'episodes/%episodes_category%\',
\'with_front\' => false
);
$args = array(
\'label\' => __( \'episodes\', \'text_domain\' ),
\'description\' => __( \'All episodes\', \'text_domain\' ),
\'labels\' => $labels,
\'supports\' => array(\'title\' ),
\'taxonomies\' => array(\'episodes_category\' , \'post_tag\'),
\'hierarchical\' => true,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 5,
\'can_export\' => true,
\'has_archive\' => \'episodes\',
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'rewrite\' => $rewrite,
\'capability_type\' => \'post\',
\'query_var\' => true,
\'menu_icon\' => \'dashicons-media-video\'
);
register_post_type( \'episodes_listing\', $args );
}
function episodes_taxomony() {
$labels = array(
\'name\' => _x( \'Episodes Categories\', \'Taxonomy General Name\', \'text_domain\' ),
\'singular_name\' => _x( \'Episodes\', \'Taxonomy Singular Name\', \'text_domain\' ),
\'menu_name\' => __( \'Episode Categories\', \'text_domain\' ),
\'all_items\' => __( \'All Items\', \'text_domain\' ),
\'parent_item\' => __( \'Parent Item\', \'text_domain\' ),
\'parent_item_colon\' => __( \'Parent Item:\', \'text_domain\' ),
\'new_item_name\' => __( \'New Item Name\', \'text_domain\' ),
\'add_new_item\' => __( \'Add new Episode Category\', \'text_domain\' ),
\'edit_item\' => __( \'Edit Item\', \'text_domain\' ),
\'update_item\' => __( \'Update Item\', \'text_domain\' ),
\'separate_items_with_commas\' => __( \'Separate items with commas\', \'text_domain\' ),
\'search_items\' => __( \'Search Items\', \'text_domain\' ),
\'add_or_remove_items\' => __( \'Add or remove items\', \'text_domain\' ),
\'choose_from_most_used\' => __( \'Choose from the most used items\', \'text_domain\' ),
\'not_found\' => __( \'Not Found\', \'text_domain\' )
);
$rewrite = array(
\'slug\' => \'episodes\',
\'with_front\' => false,
\'hierarchical\' => true
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => true,
\'public\' => true,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'show_in_nav_menus\' => true,
\'show_tagcloud\' => true,
\'query_var\' => true,
\'rewrite\' => $rewrite
);
register_taxonomy( \'episodes_category\', array(\'episodes_listing\'), $args );
}