When we select postname in in permalink settings for pretty permalink, for a custom post type the URL is http://domain.com/custom_post_type/post-slug
But some people want to append post ID at the end of the URL, like: http://domain.com/custom_post_type/post-slug/post-id
Let’s see how we can do this.
I assume, the custom post type name is product, product slug is hair-dryer, product ID is 1902. Currently the URL is http://domain.com/product/hair-dryer and we want to make it like http://domain.com/product/hair-dryer/1902. So, here is the solution:
You can include this code in your functions.php or as a wordpress mu-plugin for safety 🙂
Happy WordPressing 🙂