Sho*_*rza 1 wordpress permalinks custom-post-type
我有一个名为'Portfolio'的自定义帖子类型.当我发帖子时,它会生成url为/ portfolio/xxx.我想将其更改为"产品". 更改自定义后期类型重写 我试过这个,但它不会起作用.
小智 6
我假设你自己添加了自定义帖子类型,在这种情况下它很容易.
注册新的帖子类型时,可以为该帖子类型设置任何重写规则,作为函数中使用的参数的一部分register_post_type( 'name', $args )
.
如果您的帖子类型在前端可用并且是公开的,则默认情况下WordPress将使用自定义帖子名称作为slug.您可以按如下方式覆盖:
$args = array(
// your other arguments
'rewrite' => array(
'slug' => 'products', // use this slug instead of post type name
'with_front' => FALSE // if you have a permalink base such as /blog/ then setting this to false ensures your custom post type permalink structure will be /products/ instead of /blog/products/
),
);
register_post_type( 'portfolio', $args );
Run Code Online (Sandbox Code Playgroud)
您可以使用的其他参数记录在http://codex.wordpress.org/Function_Reference/register_post_type
归档时间: |
|
查看次数: |
7455 次 |
最近记录: |