WordPress.org

Support

Support » Plugins and Hacks » Fails when permalink has custom structure with static front (fix provided)

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.

    http://wordpress.org/extend/plugins/wp-no-category-base/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thanks for the fix!

    I didn’t test on a version less than 3.4 so I can’t guarantee prepending front will work for older versions.

    No, you don’t need to test it for WordPress version less than 3.4. Sometimes we as developer should educate users (by forcing them to upgrade) 😉

    bigj9901

    @bigj9901

    Looks like this was incorporated into the plugin but the issue still exists for me. WP 3.6.1

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fails when permalink has custom structure with static front (fix provided)’ is closed to new replies.