In WordPress, you can easily create a pretty URL by going to the Settings -> Permalinks section and update the permalink structure. However, if you are creating your own themes or plugins, there are times when you need to create a custom permalink structure.
For example: you want to implement a permalink: http://your-site.com/movies/1 which translates to http://your-site.com/index.php?movies=1.
Here’s how you do it:
In your plugin or theme’s functions.php file, add the following lines:
The first function translate the new permalink structure to the one you want.
The second function is to add the query variable into the default variable list.
The third function is to redirect the page to a custom template when the new query variable is detected.