// 記事スラッグをIDにする
function auto_slug_setting( $slug, $post_ID, $post_status, $post_type ) {
// 記事IDからを記事情報を取得
$post = get_post($post_ID);
// 初回の記事保存時にのみスラッグを記事IDに設定
if ( $post_type && $post->post_date_gmt == '0000-00-00 00:00:00' ) {
$slug = $post_ID;
}
return $slug;
}
add_filter( 'wp_unique_post_slug', 'auto_slug_setting', 10, 4 );
コメントを残す