Skip to content

Instantly share code, notes, and snippets.

@alt-karate
Last active June 27, 2019 07:18
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 alt-karate/7f7c45107f7e10995d4f54a6d5ba841a to your computer and use it in GitHub Desktop.
Save alt-karate/7f7c45107f7e10995d4f54a6d5ba841a to your computer and use it in GitHub Desktop.
/**
* スラッグの日本語禁止します
*/
function auto_post_slug( $slug, $post_ID, $post_status, $post_type ) {
if ( preg_match( '/(%[0-9a-f]{2})+/', $slug ) ) {
$slug = utf8_uri_encode( $post_type ) . '-' . $post_ID;
}
return $slug;
}
add_filter( 'wp_unique_post_slug', 'auto_post_slug', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment