fro*_*862 15 wordpress permalinks custom-post-type
我的Wordpress安装有三种帖子类型:页面,帖子和组合.目前的结构如下:
example.com/page-name
,example.com/blog
,example.com/post-name
,example.com/portfolio
,example.com/portfolio/portfolio-name
.我想改变的是单个帖子固定链接,但没有别的.我希望它成为example.com/blog/post-name.
我找不到显示如何在不影响其他类型的情况下进行此更改的文档.
编辑:我当前的永久链接结构设置为/%postname%/
,并在阅读设置下,我的帖子页面设置为博客.
register_post_type('portfolio', array(
'label' => 'Portfolio Items',
'description' => '',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'post',
'hierarchical' => true,
'rewrite' => array('slug' => 'portfolio'),
'with_front' => false,
'query_var' => false,
'has_archive' => true,
'exclude_from_search' => false,
'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes'),
'taxonomies' => array('category','post_tag'),
'labels' => array (
'name' => 'Portfolio Items',
'singular_name' => 'Portfolio Item',
'menu_name' => 'Portfolio Items',
'add_new' => 'Add Portfolio Item',
'add_new_item' => 'Add New Portfolio Item',
'edit' => 'Edit',
'edit_item' => 'Edit Portfolio Item',
'new_item' => 'New Portfolio Item',
'view' => 'View Portfolio Item',
'view_item' => 'View Portfolio Item',
'search_items' => 'Search Portfolio Items',
'not_found' => 'No Portfolio Items Found',
'not_found_in_trash' => 'No Portfolio Items Found in Trash',
'parent' => 'Parent Portfolio Item',
)
));
Run Code Online (Sandbox Code Playgroud)
soj*_*oju 42
您只需将其设置/blog/%postname%/
为永久链接结构,这不会更改您的页面永久链接.
并保持你的投资组合的永久链接,你应该设置with_front
到false
当你注册这个帖子类型.
'with_front' => bool
permastruct是否应该在前基座前面.(例如:如果您的永久链接结构是/blog/
,那么您的链接将是:false->/news/
,true->/blog/news/
).默认为true
编辑1:之后您应该清除Wordpress重写规则.
编辑2:with_front
param是一个rewrite
参数:
'rewrite' => array('slug' => 'portfolio', 'with_front' => false),
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
15942 次 |
最近记录: |