因此,我有一个目前正在进行的项目,其中我将Wordpress设置为永久链接结构/blog/%postname%,用于博客帖子和页面是域。com/页段塞/
我已经创建了一个名为“quot;“投资组合”;它有一个存档,但也有一个名为;“投资组合”;这会将公文包自定义帖子类型中的帖子拉入其中。
现在,对于公文包的slug,我已经设置了自定义重写,因为我不能与front对齐,否则slug将是/blog/公文包/postname/到我的自定义永久链接结构/blog/postname:
\'rewrite\' => array(\'slug\' => \'portfolio\', \'with_front\' => false)
这意味着公文包帖子将是/portfolio/post slug-但问题是,转到/portfolio/show归档而不是页面。
如何让它显示公文包页面而不是归档?
完全自定义post类型功能
function rbt_portfolio() {
$labels = array(
\'name\' => esc_html_x( \'Portfolios\', \'Post Type General Name\', \'jstest\' ),
\'singular_name\' => esc_html_x( \'Portfolio\', \'Post Type Singular Name\', \'jstest\' ),
\'menu_name\' => esc_html__( \'Portfolio\', \'jstest\' ),
\'name_admin_bar\' => esc_html__( \'Portfolio\', \'jstest\' ),
\'archives\' => esc_html__( \'Item Archives\', \'jstest\' ),
\'parent_item_colon\' => esc_html__( \'Parent Item:\', \'jstest\' ),
\'all_items\' => esc_html__( \'All Items\', \'jstest\' ),
\'add_new_item\' => esc_html__( \'Add New Item\', \'jstest\' ),
\'add_new\' => esc_html__( \'Add New\', \'jstest\' ),
\'new_item\' => esc_html__( \'New Item\', \'jstest\' ),
\'edit_item\' => esc_html__( \'Edit Item\', \'jstest\' ),
\'update_item\' => esc_html__( \'Update Item\', \'jstest\' ),
\'view_item\' => esc_html__( \'View Item\', \'jstest\' ),
\'search_items\' => esc_html__( \'Search Item\', \'jstest\' ),
\'not_found\' => esc_html__( \'Not found\', \'jstest\' ),
\'not_found_in_trash\' => esc_html__( \'Not found in Trash\', \'jstest\' ),
\'featured_image\' => esc_html__( \'Featured Image\', \'jstest\' ),
\'set_featured_image\' => esc_html__( \'Set featured image\', \'jstest\' ),
\'remove_featured_image\' => esc_html__( \'Remove featured image\', \'jstest\' ),
\'use_featured_image\' => esc_html__( \'Use as featured image\', \'jstest\' ),
\'inserbt_into_item\' => esc_html__( \'Insert into item\', \'jstest\' ),
\'uploaded_to_this_item\' => esc_html__( \'Uploaded to this item\', \'jstest\' ),
\'items_list\' => esc_html__( \'Items list\', \'jstest\' ),
\'items_list_navigation\' => esc_html__( \'Items list navigation\', \'jstest\' ),
\'filter_items_list\' => esc_html__( \'Filter items list\', \'jstest\' ),
);
$args = array(
\'label\' => esc_html__( \'Portfolio\', \'jstest\' ),
\'labels\' => $labels,
\'supports\' => array( \'title\', \'editor\', \'excerpt\', \'thumbnail\'),
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'menu_position\' => 5,
\'menu_icon\' => \'dashicons-index-card\',
\'show_in_admin_bar\' => true,
\'show_in_nav_menus\' => true,
\'can_export\' => true,
\'has_archive\' => true,
\'rewrite\' => array(\'slug\' => \'portfolio\', \'with_front\' => false),
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'page\',
);
register_post_type( \'portfolio\', $args );
}
add_action( \'init\', \'rbt_portfolio\', 0 );