admin管理员组

文章数量:1333385

I'm using custom post type with custom taxonomies for my website and currently my URL is as follows:

www.website/taxonomy_slug/taxonomy_category

So an example realworld URL would be:

www.website/kernal_category/filmmaking

  • The taxonomy slug is kernal_category
  • The taxonomy category is filmmaking

I want to remove the taxonomy slug so that the url would more simply read www.website/filmmaking however none of the changes I have tried work.

My current Permalink settings are set to wwww.website/%category%/ however I have tried changing this to anything else (including /%postname%/)and it seems to have no affect on my website URLs.

Could someone suggest the proper way of fixing this, and also highlight some possible obstacles that may be preventing this from working.

This link did not work for me - Remove Custom Taxonomy Slug from Permalink

I'm using custom post type with custom taxonomies for my website and currently my URL is as follows:

www.website/taxonomy_slug/taxonomy_category

So an example realworld URL would be:

www.website/kernal_category/filmmaking

  • The taxonomy slug is kernal_category
  • The taxonomy category is filmmaking

I want to remove the taxonomy slug so that the url would more simply read www.website/filmmaking however none of the changes I have tried work.

My current Permalink settings are set to wwww.website/%category%/ however I have tried changing this to anything else (including /%postname%/)and it seems to have no affect on my website URLs.

Could someone suggest the proper way of fixing this, and also highlight some possible obstacles that may be preventing this from working.

This link did not work for me - Remove Custom Taxonomy Slug from Permalink

Share Improve this question asked Jun 19, 2020 at 17:21 JamesJames 1191 silver badge5 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Why don't you try to create a slug of your own. And then link it up to your desire things.

Just use this function:

function slugify($str){
$search = array('Ș', 'Ț', 'ş', 'ţ', 'Ş', 'Ţ', 'ș', 'ț', 'î', 'â', 'ă', 'Î', 'Â', 'Ă', 'ë', 'Ë');
$replace = array('s', 't', 's', 't', 's', 't', 's', 't', 'i', 'a', 'a', 'i', 'a', 'a', 'e', 'E');
$str = str_ireplace($search, $replace, strtolower(trim($str)));
$str = preg_replace('/[^\w\d-\ ]/', '', $str);
$str = str_replace(' ', '-', $str);
return (substr($str, -1) == '-' ? substr($str, 0, -1) : $str );
}

and provide the string into this function bingo! I did little bit customization in this function.

What I am saying is create a custom-field with custom-post-type then make it read-only. And put your desire link in there. Everything will be fine.

本文标签: permalinksRemove custom taxonomy slug from URL