wp_unique_post_slug_is_bad_hierarchical_slug
Filter HookDescription
Filters whether the post slug would make a bad hierarchical post slug.Hook Information
File Location |
wp-includes/post.php
View on GitHub
|
Hook Type | Filter |
Line Number | 5463 |
Hook Parameters
Type | Name | Description |
---|---|---|
bool
|
$bad_slug
|
Whether the post slug would be bad in a hierarchical post context. |
string
|
$slug
|
The post slug. |
string
|
$post_type
|
Post type. |
int
|
$post_parent
|
Post parent ID. |
Usage Examples
Basic Usage
<?php
// Hook into wp_unique_post_slug_is_bad_hierarchical_slug
add_filter('wp_unique_post_slug_is_bad_hierarchical_slug', 'my_custom_filter', 10, 4);
function my_custom_filter($bad_slug, $slug, $post_type, $post_parent) {
// Your custom filtering logic here
return $bad_slug;
}
Source Code Context
wp-includes/post.php:5463
- How this hook is used in WordPress core
<?php
5458 * @param bool $bad_slug Whether the post slug would be bad in a hierarchical post context.
5459 * @param string $slug The post slug.
5460 * @param string $post_type Post type.
5461 * @param int $post_parent Post parent ID.
5462 */
5463 $is_bad_hierarchical_slug = apply_filters( 'wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent );
5464
5465 if ( $post_name_check
5466 || in_array( $slug, $feeds, true ) || 'embed' === $slug
5467 || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug )
5468 || $is_bad_hierarchical_slug
PHP Documentation
<?php
/**
* Filters whether the post slug would make a bad hierarchical post slug.
*
* @since 3.1.0
*
* @param bool $bad_slug Whether the post slug would be bad in a hierarchical post context.
* @param string $slug The post slug.
* @param string $post_type Post type.
* @param int $post_parent Post parent ID.
*/
Quick Info
- Hook Type: Filter
- Parameters: 4
- File: wp-includes/post.php
Related Hooks
Related hooks will be displayed here in future updates.