Ready to get started?Download WordPress


How to limit the length of an URL (Post slug)? (6 posts)

  1. guarriman
    Posted 8 years ago #

    In July, I posted here a doubt about how to limit the length of an URL (Post slug):

    The unique solution proposed was do it by hand, but I'm still searching an automatic one.

    Does anybody know it? Thx.

  2. Well, the problem with automatic is you may end up with ugly URLs.


    Post title - This is my post title and it's really cool
    Auto-slug - This-is-my-pos


    I'd say just use the advanced editing form as your default and make your own slug for those long titled posts as you type them. Is it really that hard? ;)

  3. guarriman
    Posted 8 years ago #

    Hi Viper007Bond. Thank you very much for your answer.

    I don't mind if the URLs are ugly.

    Anyway, I modified 'functions-formatting.php', and added this line
    at the end of 'function sanitize_title' (before returning $title):
    $title = substr($title, 0, 30);

    It works.

  4. guarriman
    Posted 8 years ago #

    Mmm... it doesn't work :(

    If I include that line, then old permalinks don't appear.

  5. proudmemberofeff
    Posted 7 years ago #

    Can anyone make a plugin that does this? Or include this option in the official wordpress code? I run a multi-user blog, and while I can usually remember to truncate my post slugs, other people don't. I want to prevent the URLs from getting too long *automatically.*

  6. mightymouse
    Posted 7 years ago #

    I've just created a plugin to do this. Take a look at the anouncement: http://wordpress.org/support/topic/94617
    and download the plugin at:


Topic Closed

This topic has been closed to new replies.

About this Topic