0

I have a little problen with URL structure because i am using a custom structure of my Wordpress page.

Currently i am using normal pages as categories.

www.domain.tld/my_page

This page contains all posts from a normal Wordpress category. Page is autogenerated with plugin. My problem is when i am using breadcrumbs, when i go into post i get following breadcrumbs.

Home > Category > Post

This should be

Home > Category > Post (where category should link to my_page instead of category)

I can manage this with normal rewritetrule in .htaccess like this:

RewriteRule ^category/name_of_category/ http://domain.tld/name_of_category/ [R=301,L]

Is is possible to make rewritetule in .htaccess that removes /category/ completely from URL strucure? This will make my structure work like it should, without me having to ad new rule in .htaccess everytime i ad new category.

Hope someone can help.

4

1 回答 1

2
function kill_category_base ($string) {
   $string = str_replace('category/', '', $string);
   return $string;
}
add_filter('category_link', 'kill_category_base');
RewriteRule ^([^/.]+)/(page/([0-9]+)|feed)$ index.php/category/$1/$2 [L]  # redirect category    pages and feeds

在这里找到删除类别后缀永久链接

于 2013-10-27T12:39:07.013 回答