apply_filters( 'pre_wp_unique_post_slug', string|null $override_slug, string $slug, int $post_id, string $post_status, string $post_type, int $post_parent )
- Since
- 5.1.0
Filters the post slug before it is generated to be unique.
Description
Returning a non-null value will short-circuit the unique slug generation, returning the passed value instead.
Compatibility
- WordPress
- since 5.1.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Parameters
$override_slugstring|null- Short-circuit return value.
$slugstring- The desired slug (post_name).
$post_idint- Post ID.
$post_statusstring- The post status.
$post_typestring- Post type.
$post_parentint- Post parent ID.
Where this hook fires · 1
wp-includes/post.php:5400wp_unique_post_slug()
Source code
* @param string $slug The desired slug (post_name). * @param int $post_id Post ID. * @param string $post_status The post status. * @param string $post_type Post type. * @param int $post_parent Post parent ID. */ $override_slug = apply_filters( 'pre_wp_unique_post_slug', null, $slug, $post_id, $post_status, $post_type, $post_parent ); if ( null !== $override_slug ) { return $override_slug; } global $wpdb, $wp_rewrite;Changelog
Introduced in 5.1.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.8.8 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
- Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.