[wp-trac] [WordPress Trac] #36849: Filter to limit length of post slug (filter for _truncate_post_slug)

WordPress Trac noreply at wordpress.org
Sat May 21 17:37:36 UTC 2016


#36849: Filter to limit length of post slug (filter for _truncate_post_slug)
-------------------------------+------------------------------
 Reporter:  wp-entwickler.at   |       Owner:
     Type:  enhancement        |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Posts, Post Types  |     Version:  4.5.2
 Severity:  normal             |  Resolution:
 Keywords:                     |     Focuses:
-------------------------------+------------------------------

Comment (by boonebgorges):

 @wp-entwickler.at Thanks for the ticket!

 `wp_unique_post_slug()` truncates to 200 characters because the
 `post_name` column in the `wp_posts` table is `VARCHAR(200)`. In other
 words, WP truncates like it does to maintain data integrity, and to
 provide a smoother experience than simply rejecting post slugs that are
 too long.

 I don't think we can introduce a simple filter for the truncation length,
 because we need to ensure that slugs still fit in the the database column.
 In other words, you shouldn't be able to filter to `250`. So we'd need a
 bit of extra logic.

 What is the use case for wanting shorter slugs? If it's something fairly
 general, it makes the case stronger for adding a filter here.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36849#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list