Created
May 14, 2020 08:26
-
-
Save antonlukin/c8b5da3a8e92919ff7b7e1ba47c611b3 to your computer and use it in GitHub Desktop.
Prevent to create WordPress posts and pages with custom reserved slug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('wp_unique_post_slug_is_bad_flat_slug', function($bad_slug, $slug) { | |
if($slug === 'social') { | |
return true; | |
} | |
return $bad_slug; | |
}, 10, 2); | |
add_filter('wp_unique_post_slug_is_bad_hierarchical_slug', function($bad_slug, $slug) { | |
if($slug === 'social') { | |
return true; | |
} | |
return $bad_slug; | |
}, 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment