If you’re comfortable with PHP, it would be possible to keep track of when the slug is updated. The only way I can think of is a bit complicated:
-
Make sure revisions are enabled, both for your install and for the post type you’re targeting. You’ll have to determine how many revisions you want to save, which will be a balance between how many times you think someone might change the post (whether it’s a slug change, or content, or anything about the post) and how bloated you allow the database to become with all that extra data.
-
Add version control for a postmeta field you will use to keep track of the slug with every revision. First install the plugin “WP-Post-Meta-Revisions.” Then, in a custom plugin, or a child theme’s
functions.php
file:
add_filter('wp_post_revision_meta_keys', 'wpse_track_slug_postmeta');
function wpse_track_slug_postmeta() {
// Access the array of postmeta keys that is already versioned
global $versionedKeys;
// Add your custom postmeta key to the array
$versionedKeys[] = 'versionedSlug';
// Pass the array back to WordPress
return $versionedKeys;
}
Once this is done, every time you save a revision, the postmeta “versionedSlug” for that specific revision will be saved.
- Every time a revision is saved, you need to tell WP to save the slug as that “versionedSlug” postmeta. You can use the
wp_insert_post
hook:
// Every time WP inserts a post, run this function
add_action('wp_insert_post', 'wpse_save_slug_postmeta');
function wpse_save_slug_postmeta($post_id, $post, $update) {
// Make sure this is a revision
if(wp_is_post_revision($post_id)) {
// Save the slug as postmeta
// First parameter is the post ID of the revision
// Second parameter is what you want to call this postmeta key
// Third parameter is what you're saving - the slug itself
update_post_meta($post->ID, 'versionedSlug', $post->slug);
}
}
You will then have to decide how you want to access this data. If you just want to browse a post’s revisions, the revision comparison view will show you when the slug changed because it’s now explicitly saved as postmeta. You could also create various reports or widgets, depending on your needs.