WordPress.org

Ready to get started?Download WordPress

Forums

WP No Category Base
Fails when permalink has custom structure with static front (fix provided) (3 posts)

  1. maximinime
    Member
    Posted 1 year ago #

    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/

  2. WPSpeak
    Member
    Posted 1 year ago #

    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) ;)

  3. bigj9901
    Member
    Posted 7 months ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic