Skip to content

Instantly share code, notes, and snippets.

@antonlukin
Created May 14, 2020 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antonlukin/c8b5da3a8e92919ff7b7e1ba47c611b3 to your computer and use it in GitHub Desktop.
Save antonlukin/c8b5da3a8e92919ff7b7e1ba47c611b3 to your computer and use it in GitHub Desktop.
Prevent to create WordPress posts and pages with custom reserved slug
<?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