If I were to edit a post or a page, how would I determine what the slug was before the edit, and again afterwards to compare them and see if it was changed? Also, would the same method work for any Custom Post Types created, or is that done differently?

1 Answer 1


If the post/page was previously published, and you changed the slug when you edited the page, the old slug gets put into the post meta table with the name _wp_old_slug. So you can use get_post_meta( $post->ID, '_wp_old_slug', $single = false ); to retrieve the former slug(s). I see no reason this wouldn't work with CPTs, as they're just a special type of post.


  • Thanks for the reply. I'll give that a try. Sorry it took so long for me to get back, I haven't been home.
    – user20746
    Jun 19, 2013 at 1:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.