最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Divi change project category slug

programmeradmin2浏览0评论

How to change taxonomy urls in wordpress?

Following along with this question and this one

But can not get the desired outcome.

The default is:

example/project_category/%category%/

What I want is:

example/stainless-steel-products/%category%/

I have changed the slug of the project archive so that example/stainless-steel-products/ is the project archive.

Below is the code used to achieve that.

// Change peralinks projects
function custom_project_slug () {
    return array(
    'feeds' => true,
    'slug' => 'stainless-steel-products',
    'with_front' => false,
    );
}
add_filter( 'et_project_posttype_rewrite_args', 'custom_project_slug' );

?>

How do I change the slug of the project categories so that it is a child of the project archive? Thanks for any help in advance!

How to change taxonomy urls in wordpress?

Following along with this question and this one

But can not get the desired outcome.

The default is:

example.com/project_category/%category%/

What I want is:

example.com/stainless-steel-products/%category%/

I have changed the slug of the project archive so that example.com/stainless-steel-products/ is the project archive.

Below is the code used to achieve that.

// Change peralinks projects
function custom_project_slug () {
    return array(
    'feeds' => true,
    'slug' => 'stainless-steel-products',
    'with_front' => false,
    );
}
add_filter( 'et_project_posttype_rewrite_args', 'custom_project_slug' );

?>

How do I change the slug of the project categories so that it is a child of the project archive? Thanks for any help in advance!

Share Improve this question edited Mar 17, 2021 at 6:40 Aran Joyce asked Mar 15, 2021 at 5:38 Aran JoyceAran Joyce 131 silver badge4 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 2
add_filter( 'register_taxonomy_args', 'change_taxonomies_slug', 10, 2 );
function change_taxonomies_slug( $args, $taxonomy ) {

   if ( 'project_category' === $taxonomy ) {
      $args['rewrite']['slug'] = 'stainless-steel-products';
   }

   return $args;
}

You can use this Plugin:

https://wordpress.org/plugins/custom-post-type-permalinks/

It works fine. U only need also to add this in function php:

// Change peralinks projects
function custom_project_slug () {
    return array(
    'feeds' => true,
    'slug' => 'stainless-steel-products',
    'with_front' => false,
    );
}
add_filter( 'et_project_posttype_rewrite_args', 'custom_project_slug' );
发布评论

评论列表(0)

  1. 暂无评论