The MU forums have moved to WordPress.org

Category Slug (41 posts)

  1. yashnikov
    Member
    Posted 15 years ago #

    Hi, it seems Wordpress MU doesn't support Category Slug (Like in 'normal' WP)? Why?

  2. drmike
    Member
    Posted 15 years ago #

    You need to expand that a bit more because I don't understand the point you're trying to raise here.

  3. yashnikov
    Member
    Posted 15 years ago #

    Sorry for my bad english :)

    I have a category Фильм ('Film' in russian language) and want to use Category Slug 'Film'. It's posible in normal WP (not Mu) - just go to Manage > Categories and click Edit. In the window "Edit category" you'll see some fields: Category name, Category slug, Category parent and Description. Unfortunately, there is no Category slug in Wordpress Mu. Why?

  4. a-bishop
    Member
    Posted 15 years ago #

  5. yashnikov
    Member
    Posted 15 years ago #

    I know that URI with cyrillic letters works fine. But I want Category Slug in Mu :)

  6. a-bishop
    Member
    Posted 15 years ago #

    Categories also work: "This entry was posted on Понедельник, Ноябрь 27th, 2006 at 3:59 pm and is filed under Новости." Point your mouse on the link "Новости" to check.

  7. conpeo
    Member
    Posted 15 years ago #

    how to edit category slug in WPMU?
    function like WP (Manage Categories SubPanel)

  8. Ovidiu
    Member
    Posted 15 years ago #

    that doesn't work, I already raised that issue once here in the forum because I had changed a category name and later wanted to make a category with the same name, but the old category had retained its category slug, so I'd like wpmu to at least change the slug when the name changes or allow us to change the slug manually.

  9. mypatricks
    Member
    Posted 15 years ago #

    I don't know why removed it. But if you want get back the work may try to add these:

    <tr>
    <th scope="row" valign="top"><label for="category_nicename"><?php _e('Category slug:') ?></label></th>
    <td><input name="category_nicename" id="category_nicename" type="text" value="<?php echo attribute_escape($category->category_nicename); ?>" size="40" /></td>
    </tr>

    after this line in /wp-admin/edit-category-form.php

    <td width="67%"><input name="cat_name" id="cat_name" type="text" value="<?php echo attribute_escape($category->cat_name); ?>" size="40" /></td>
    </tr>

  10. binh
    Member
    Posted 14 years ago #

    Is there a plugin to make it work now?

    I don't like the way it's displaying on APmart.com at the moment. The category slug is too long and make the whole URL structure long. Also, is there a way to make the category slug not nested...
    like

    /pdas/
    /phones/
    /phone-pdas/

    instead of
    /phones-pdas/pdas
    /phones-pdas/phones
    /phones-pdas/

  11. MrBrian
    Member
    Posted 14 years ago #

    First, you're in the wrong forum. This is for Wordpress Multi-User.

    Not sure about removing nesting. This *might* help:
    http://fortes.com/projects/wordpress/top-level-cats/

  12. dancing dragon
    Member
    Posted 14 years ago #

    I have the same question as the original poster from a year ago. Is there a way to get category slugs to work in Wordpress MU? (And if not, why not?)

    For example, someone wants to have a really long category name display on the page but it's not good for the URL. For example, "Nth International Conference on Y in Z"

    If binh is in the wrong forum, using Wordpress instead of Wordpress MU, the category slug functionality in Wordpress is pretty obvious and simple to use (Manage -> Categories). Not sure why anyone would have a question about how it works on Wordpress.

  13. takuya
    Member
    Posted 14 years ago #

    I'd like this function on future release of wpmu.

  14. richardxthripp
    Member
    Posted 14 years ago #

    I think users should be able to change the slugs of their categories and tags also. I noticed that when you go to Manage > Tags and click a tag, the tag slug field is still there, but whatever you type in it is ignored. For the category edit pages, the slug field is completely removed.

    The slug field may be removed / non-working in MU to keep compatibility with the wp_sitecategories table; we don't want users to be able to change the slugs there. But that can be worked around I'm sure. WPMU v2.7, maybe?

  15. binh
    Member
    Posted 14 years ago #

    Firsly, MrBrian, it's funny when you conclude that i'm in the wrong forum. What make you think apmart.com is running on normal WordPress? But that's OK, I forgot to mention it, so my bad. I'm running all my blogs on MU.

    I think early one I had a fix here: How to Change WPMU Category Name or Slug

    Basically, I could enable the category slug text box, but it still wont' work. In fact it causes more pain than gain. So at the moment I am still stuck with very long slug, or short slug and short category name.

    So still waiting for a plugin or whatever fix for it.

  16. dancing dragon
    Member
    Posted 14 years ago #

    I tried what mypatricks posted earlier, but that only makes the "Category Slug" field appear on the Manage -> Categories page. It populates the text box with the existing category slug but after editing and submitting the form, the value remains unchanged.

    Anybody know how to get the edited category slug into the database?

  17. dancing dragon
    Member
    Posted 14 years ago #

    Okay, I took a look at this myself and this is what I come up with so far. I am using WPMU 2.6.1.

    wp-admin/categories.php, line 81 - case: 'editedcat'. This tells me to go look for a function wp_update_category.

    wp-admin/includes/taxonomy.php, line 102 - function wp_update_category. This calls function wp_insert_category (defined at line 53). This tells me to look for a function wp_update_term, because the edited category slug variable mysteriously reverts to the default value after this call.

    wp-includes/taxonomy.php, line 1467 - function wp_update_term. The edited category slug reverts to the default value after the call to apply_filters('pre_update_term', ...)

    wp-admin/includes/mu.php, line 384 - add_filter('wp_update_term', 'sync_slugs', ...). And on line 380, function sync_slugs. This looks like it.

    function sync_slugs( $term, $taxonomy, $args ) {
    $args[ 'slug' ] = sanitize_title( $args[ 'name' ] );
    return $args;
    }

    I haven't actually tried out a fix yet because I am looking at this on a semi-live site and have not yet set up a test environment. Not sure yet where exactly to put in a fix where it won't affect anything else.

    I have literally only started looking at WPMU code about an hour ago so I am not familiar with the design, so any help from more knowledgeable people is appreciated.

    And the question still remains, why was this functionality removed in the first place?

  18. illutic
    Member
    Posted 14 years ago #

    If I'm not mistaken there's an easy way to add a category base for new blogs. All you need is the new blog settings plugin and add this to the file (in the function):
    add_option('category_base', 'CATEGORYBASE');

    Haven't tried it myself, but seeing the options are added in wp-admin/includes/schema.php and the add_option category_base does exist, this should work.

  19. dancing dragon
    Member
    Posted 14 years ago #

    illutic, this thread is about category slug not category base....

  20. dancing dragon
    Member
    Posted 14 years ago #

    Something else I discovered is that I cannot edit tag slugs in addition to category slugs. The difference between the two is that the text box for editing tag slugs is present on the WPMU admin interface while the text box for editing category slugs is not (in WPMU 2.6.1).

    In searching the forum, it looks like someone had the problem with not being able to edit tag slugs in WPMU 1.5.1 as well, and it does not look like it was addressed:
    http://mu.wordpress.org/forums/topic.php?id=8310

    Is this a bug?

  21. MrBrian
    Member
    Posted 14 years ago #

    Since i've noticed you guys posting and investing this issue, i finally said "Fine, i'll take a look". My install is 2.6.1. I tested both the tagbase and category base. In my install, they are both editable via Settings->Permalinks. This is done on a perblog basis unless you do it automagically (it's easy). I then tested the new links and they work as intended.

    For the people that are updating the category/tag bases and not seeing any changes, they are most likely not reading the top message after they update that says either "Permalink structure updated." or "You should update your .htaccess now.". The latter would obviously mean you need to make changes manually because WPMU is unable to.

    If I missed the ball on the issue you guys are having, let me know.

  22. dancing dragon
    Member
    Posted 14 years ago #

    I already replied once in this thread to clarify that this is about *slug* not *base*. Those are two different things.

    For example, if one has a category named "Category Name That Is Too Long For The URL", the default permalink is http://domain.tld/blog/category/category-name-that-is-too-long-for-the-url/.

    One might want to change the category *slug* to something different, such as "shorter-slug", and that means the permalink would be http://domain.tld/blog/category/shorter-slug/.

    Similarly for tag names and slugs.

    This functionality can be seen for tags on the "Edit Tag" page at Manage -> Tags -> (select a tab). There you will see two text boxes, one for "Tag Name" and one for "Tag Slug".

    Is the subject of this thread clear now?

  23. MrBrian
    Member
    Posted 14 years ago #

    Ah, now I understand. Well it looks like this functionality has been removed... but have you tried editing the slug directly in the database? It's under wp_x_terms

  24. dancing dragon
    Member
    Posted 14 years ago #

    Yes, that is why several people have been asking why category slug editing was removed?

    However, for tag slugs (vs. category slugs), the functionality exists but doesn't work. If you go to the "Edit Tag" page I mentioned above and try to edit the "Tag Slug", you can enter anything into the text box and it won't change the value after you submit the form. The text box will repopulate with the old value.

    That to me looks like a bug, not just removed functionality.

  25. MrBrian
    Member
    Posted 14 years ago #

    Yes, i've been looking at that. Heres why:

    in "wp-admin/includes/mu.php" the following code prevents the slug from being renamed:

    function sync_slugs( $term, $taxonomy, $args ) {
    	$args[ 'slug' ] = sanitize_title( $args[ 'name' ] );
    	return $args;
    }
    add_filter( 'pre_update_term', 'sync_slugs', 10, 3 );

    I don't know why custom slugs were removed for categories and tags, but it was done intentionally. You should put in a trac ticket to remove the slug inputbox from the tags-form (as that is a bug) and to also inquire about the reason for the removed functionality. If you want to enable slugs anyway, just comment out the filter.

  26. dancing dragon
    Member
    Posted 14 years ago #

    Yes, that is what I already posted 8 posts up.

    I'm looking at the history associated with this issue but I can't find a reason given for the removal of the functionality.

    http://trac.mu.wordpress.org/changeset/1136
    http://trac.mu.wordpress.org/ticket/476

    I'm just wondering if it was removed for an actual reason where if I were to take out the forced sanitize_title filter, will something else break? ... and if nothing would break by doing this, then it does not make sense for the functionality not to be there. I don't see why regular WordPress can have this functionality and WordPress MU can not.

    Anyway, I guess I will open a ticket in Trac for the tags-form, now that at least one other person agrees that that is a bug.

  27. dancing dragon
    Member
    Posted 14 years ago #

    I might be talking to myself here but I was looking at the history and saw that the reason why all category slugs were made to always match the name was to fix this ticket, http://trac.mu.wordpress.org/ticket/476. Here, the "bug" was said to be reproduced by:
    * rename 'Uncategorized' cat to 'Anything';
    * slug still points into /category/uncategorized.

    But this is not a bug! Look at regular WordPress and this is how it's supposed to work. The category slug is supposed to keep pointing to the old slug when the user changes the name of an existing category.

    That is because changing the name of an existing category is a "cosmetic" change for presentation. It can't be assumed that the user also wants to change the slug to match. That breaks links from outside when maybe the user just wanted to change the display name in the HTML and not the URL. The user is supposed to manually edit the slug name if he wants it to match a change of name on an existing category.

    As the ticket #476 itself said, the problem was caused originally by the removal of the input field for "Category Slug" making the user unable to edit it through the admin interface. Reason for removal is still unknown. For some reason, it was decided to work around this by forcing the slug to be uneditable on the backend as well and always matching the category name. I hope there was a really good reason why the "Category Slug" input field was removed from the admin interface because it seems to have caused quite a number of problems.

  28. MrBrian
    Member
    Posted 14 years ago #

    I only posted the exact code and solution for people that want to change the slug and need a clear answer. We can all agree that you can easily change the slug, the only question remains is why this is not a permitted action for bloggers.

    I took a look at wordpress.com and they don't allow the tag or category slug to be changed either. Only difference is they have removed the slug input for the tag form like should be done for WPMU. My guess is it's a security risk, but I don't know why. There are several differences between normal Wordpress and WPMU for security reasons (such as being able to insert javascript into widgets), so it's not always fair to compare normal wordpress to WPMU. Hope donncha can shed some light on the specifics in your trac ticket.

  29. dancing dragon
    Member
    Posted 14 years ago #

    This is the fix I am now using (in WPMU 2.6.1) to make both category and tag slugs editable. I have yet to see if anything breaks because of it:

    wp-admin/edit-category-form.php

    Add the following between the table rows for "Category Name" and "Category Parent":

    <tr class="form-field">
            <th scope="row" valign="top"><label for="category_nicename"><?php _e('Category Slug') ?></label></th>
            <td><input name="category_nicename" id="category_nicename" type="text" value="<?php echo attribute_escape($category->category_nicename); ?>" size="40" />
            <?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></td>
        </tr>

    wp-includes/taxonomy.php

    Comment out the following line from the function wp_update_term:

    //$args = apply_filters( 'pre_update_term', $term, $taxonomy, $args );

    This function wp_update_term is called from only 3 places:

    > find . -follow -exec grep "wp_update_term(" {} \; -print
                    $cat_ID = wp_update_term($cat_ID, 'category', $args);
    ./wp-admin/includes/taxonomy.php
            $ret = wp_update_term($tag_ID, 'post_tag', $_POST);
    ./wp-admin/edit-tags.php
            $update =  wp_update_term($cat_ID, 'link_category', $_POST);
    ./wp-admin/link-category.php
    function wp_update_term( $term, $taxonomy, $args = array() ) {
    ./wp-includes/taxonomy.php

    Looking at those, I *think* the change to the function wp_update_term is okay.

  30. MrBrian
    Member
    Posted 14 years ago #

    You don't need to edit the taxonomy file. That way will disable the filter completely so that other plugins that make use of it will be unable to. The proper way would be to comment out the add_filter line in mu.php like I mentioned further up.

About this Topic

  • Started 15 years ago by yashnikov
  • Latest reply from Viennese