pre_wp_unique_post_slug
Filters the post slug before it is generated to be unique.
Returning a non-null value will short-circuit the unique slug generation, returning the passed value instead.
Использование
add_filter( 'pre_wp_unique_post_slug', 'wp_kama_pre_wp_unique_post_slug_filter', 10, 6 );
/**
* Function for `pre_wp_unique_post_slug` filter-hook.
*
* @param string|null $override_slug Short-circuit return value.
* @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.
*
* @return string|null
*/
function wp_kama_pre_wp_unique_post_slug_filter( $override_slug, $slug, $post_id, $post_status, $post_type, $post_parent ){
// filter...
return $override_slug;
}
- $override_slug(строка|null)
- Short-circuit return value.
- $slug(строка)
- The desired slug (post_name).
- $post_id(int)
- Post ID.
- $post_status(строка)
- The post status.
- $post_type(строка)
- Post type.
- $post_parent(int)
- Post parent ID.
Список изменений
| С версии 5.1.0 | Введена. |
Где вызывается хук
pre_wp_unique_post_slug
wp-includes/post.php 5486
$override_slug = apply_filters( 'pre_wp_unique_post_slug', null, $slug, $post_id, $post_status, $post_type, $post_parent );
Где используется хук в WordPress
wp-includes/default-filters.php 749
add_filter( 'pre_wp_unique_post_slug', 'wp_filter_wp_template_unique_post_slug', 10, 5 );