Support » Requests and Feedback » Duplicate category names/slugs with different parents

  • OK, I can understand not wanting duplicate categories and slug’s. But when they are have different Parent categories, WordPress should be able to handle that, shouldn’t it?

    /Windows/Applications

    and

    /Mac/Applications

    should be able to co-exist.

    I’ve seen similiar requests on the ‘trac’ website for WordPress with what looks like a target of WordPress 2.9!

Viewing 4 replies - 1 through 4 (of 4 total)
  • yea, originally, you could work around it by using an unique slug but that work around doesn’t work with 2.7.x
    Although I submitted a ticket (#9335) for it, the only way might be to add that functionality yourself (sadly).
    I did it by editing admin-ajax.php (line 312) to check the slug, not the “cat_name” for uniqueness.

    Hi MoFOQ

    What code did you have to enter to do this. Ive found where it is and that you need to replace the ‘cat_name’ but what with? is it simply ‘slug’?

    Thanks for your help!

    Find the following code (lines 312-318) in wp-admin/admin-ajax.php:

    if ( category_exists( trim( $_POST['cat_name'] ) ) ) {
    		$x = new WP_Ajax_Response( array(
    			'what' => 'cat',
    			'id' => new WP_Error( 'cat_exists', __('The category you are trying to create already exists.'), array( 'form-field' => 'cat_name' ) ),
    		) );
    		$x->send();
    	}

    Replace with this code:

    if ( category_exists( trim( $_POST['category_nicename'] ) ) ) {
    		$x = new WP_Ajax_Response( array(
    			'what' => 'cat',
    			'id' => new WP_Error( 'cat_exists', __('The category you are trying to create already exists.'), array( 'form-field' => 'category_nicename' ) ),
    		) );
    		$x->send();
    	}

    What you are doing is changing the instances of “cat_name” with “category_nicename”, This has it check the slug for uniqueness, and not the name.

    I tested briefly for myself and it seems to be working.

    Is there any resolution for this problem? The code sample given above doesn’t solve the issue described in the first post.

    My issue is the same (with WordPress 2.8):

    Ideally, my site’s navigation (www.cmsgoodies.com) is supposed to be this way:

    http://www.cmsgoodies.com/drupal/themes/
    http://www.cmsgoodies.com/wordpress/themes/

    BUT … after I have created the first of ‘themes’ slug for lets say drupal, then I am just unable to create another slug called ‘themes’ for wordpress bcoz WP wants the slug to be totally unique!

    So how is one supposed to go around this problem? I don’t wish to compromise on the Information Architecture of my site. Any hack? Any tips? Solutions?

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Duplicate category names/slugs with different parents’ is closed to new replies.