Truncates a post slug.
Description
See also
Parameters
$slug
stringrequired- The slug to truncate.
$length
intoptional- Max length of the slug. Default 200 (characters).
Default:
200
Source
function _truncate_post_slug( $slug, $length = 200 ) {
if ( strlen( $slug ) > $length ) {
$decoded_slug = urldecode( $slug );
if ( $decoded_slug === $slug ) {
$slug = substr( $slug, 0, $length );
} else {
$slug = utf8_uri_encode( $decoded_slug, $length, true );
}
}
return rtrim( $slug, '-' );
}
Changelog
Version | Description |
---|---|
3.6.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.