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 badges1 Answer
Reset to default 0Why 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
版权声明:本文标题:permalinks - Remove custom taxonomy slug from URL 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742332773a2455024.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论