WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. guarriman
    Member
    Posted 8 years ago #

    In July, I posted here a doubt about how to limit the length of an URL (Post slug):
    http://wordpress.org/support/topic/39754

    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.

    Example:

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

    Eww.

    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
    Member
    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
    Member
    Posted 8 years ago #

    Mmm... it doesn't work :(

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

  5. proudmemberofeff
    Member
    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
    Member
    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:
    http://www.york-newyork.com/seo-plugin-wordpress-urls/

    cheers,
    mightymouse

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags