WPDev.one
Core Function
View Source on Trac ↗

wp_unique_post_slug()

wp_unique_post_slug( mixed $slug, mixed $post_id, mixed $post_status, mixed $post_type, mixed $post_parent )

Computes a unique slug for the post, when given the desired slug and some post details.

Parameters 5 required

Name / Type Description
$slug
string

The desired slug (post_name).

Required
$post_id
int

Post ID.

Required
$post_status
string

No uniqueness checks are made if the post is still draft or pending.

Required
$post_type
string

Post type.

Required
$post_parent
int

Post parent ID.

Required

Return Value

(string)
Unique slug for the post, based on $post_name (with a -1, -2, etc. suffix)

Function Information

Since Version
2.8.0
Source File
wp-includes/post.php
Advertisement