Filter hook 'wp_unique_post_slug'

in WP Core File wp-includes/post.php at line 5548

View Source

wp_unique_post_slug

Filter Hook
Description
Filters the unique post slug.

Hook Information

File Location wp-includes/post.php View on GitHub
Hook Type Filter
Line Number 5548

Hook Parameters

Type Name Description
string $slug The post slug.
int $post_id Post ID.
string $post_status The post status.
string $post_type Post type.
int $post_parent Post parent ID
string $original_slug The original post slug.

Usage Examples

Basic Usage
<?php
// Hook into wp_unique_post_slug
add_filter('wp_unique_post_slug', 'my_custom_filter', 10, 6);

function my_custom_filter($slug, $post_id, $post_status, $post_type, $post_parent, $original_slug) {
    // Your custom filtering logic here
    return $slug;
}

Source Code Context

wp-includes/post.php:5548 - How this hook is used in WordPress core
<?php
5543  	 * @param string $post_status   The post status.
5544  	 * @param string $post_type     Post type.
5545  	 * @param int    $post_parent   Post parent ID
5546  	 * @param string $original_slug The original post slug.
5547  	 */
5548  	return apply_filters( 'wp_unique_post_slug', $slug, $post_id, $post_status, $post_type, $post_parent, $original_slug );
5549  }
5550  
5551  /**
5552   * Truncates a post slug.
5553   *

PHP Documentation

<?php
/**
	 * Filters the unique post slug.
	 *
	 * @since 3.3.0
	 *
	 * @param string $slug          The post slug.
	 * @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
	 * @param string $original_slug The original post slug.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 6
  • File: wp-includes/post.php
Related Hooks

Related hooks will be displayed here in future updates.