Skip to main content

Change Post's slug

Is there a way, such as a code snippet or hook, to automatically change a post’s slug when creating a post—for example, to use a numeric ID instead of a string? The automatically generated slug is currently unsuitable for non-English languages.

Rakid Hasan

To use the post ID as the slug instead of the post title, you can add this PHP code snippet to your site via your theme's functions.php file or a snippet plugin.