Filter hook 'wp_unique_post_slug_is_bad_flat_slug'

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

View Source

wp_unique_post_slug_is_bad_flat_slug

Filter Hook
Description
Filters whether the post slug would be bad as a flat slug.

Hook Information

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

Hook Parameters

Type Name Description
bool $bad_slug Whether the post slug would be bad as a flat slug.
string $slug The post slug.
string $post_type Post type.

Usage Examples

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

function my_custom_filter($bad_slug, $slug, $post_type) {
    // Your custom filtering logic here
    return $bad_slug;
}

Source Code Context

wp-includes/post.php:5519 - How this hook is used in WordPress core
<?php
5514  		 *
5515  		 * @param bool   $bad_slug  Whether the post slug would be bad as a flat slug.
5516  		 * @param string $slug      The post slug.
5517  		 * @param string $post_type Post type.
5518  		 */
5519  		$is_bad_flat_slug = apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type );
5520  
5521  		if ( $post_name_check
5522  			|| in_array( $slug, $feeds, true ) || 'embed' === $slug
5523  			|| $conflicts_with_date_archive
5524  			|| $is_bad_flat_slug

PHP Documentation

<?php
/**
		 * Filters whether the post slug would be bad as a flat slug.
		 *
		 * @since 3.1.0
		 *
		 * @param bool   $bad_slug  Whether the post slug would be bad as a flat slug.
		 * @param string $slug      The post slug.
		 * @param string $post_type Post type.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-includes/post.php
Related Hooks

Related hooks will be displayed here in future updates.