I don’t have much experience with coding rewrites, but could you just add $post->post_name
into your return statement?
return home_url('equipment/' . $post->ID . '-' . $post->post_name );
There are a few other ways to change the permalinks that I have used that may also help you:
- The easiest way to change your permalink structure is probably to use a custom structure by going to the admin menu, settings > permalinks. Select custom structure and set it to
/%post_id%-%postname%/
- If you are looking to edit the permalink structure for the specific post type without touching any code or another post type, I would suggest downloading a plugin like “Custom Post Type Permalinks” or “Simple Post Type Permalinks” both by Toro_Unit.
In regards to the unique identifier, you want to remove at the end.. I don’t have that answer. However, if you are willing to use a .htacess rewrite instead of php, you may want to give this a try:
https://stackoverflow.com/questions/14635438/remove-trailing-number-from-url-via-htaccess