Fails when permalink has custom structure with static front (fix provided)
-
The URLs became inconsistent after activating this plugin.
The function
no_category_base_permastruct()
replaces the entire permalink structure instead of removing only the category base. For example, if my structure is/blog/%category%/%postname%/
the category structure is initially/blogs/category/%category%
. Removing the base with this plugin should make it/blogs/%category%
, but instead it was just%category%
.This could be fixed by including the existing
front
like so:function no_category_base_permastruct() { global $wp_rewrite, $wp_version; if (version_compare($wp_version, '3.4', '<')) { // For pre-3.4 support $wp_rewrite -> extra_permastructs['category'][0] = $wp_rewrite->front . '%category%'; } else { $wp_rewrite -> extra_permastructs['category']['struct'] = $wp_rewrite->front . '%category%'; } }
I didn’t test on a version less than 3.4 so I can’t guarantee prepending
front
will work for older versions.https://www.ads-software.com/extend/plugins/wp-no-category-base/
- The topic ‘Fails when permalink has custom structure with static front (fix provided)’ is closed to new replies.