How to append Post ID at the end of the URL for a Custom Post Type

When we select postname in in permalink settings for pretty permalink, for a custom post type the URL is

But some people want to append post ID at the end of the URL, like:

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 and we want to make it like So, here is the solution:

You can include this code in your functions.php or as a wordpress mu-plugin for safety 🙂

Happy WordPressing 🙂

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *