Is there any way to set my permalinks to keep their exact link. If I have a post like this one http://blog.rigo.ro/?p=11, then I would like that every time I edit the post to keep this link.

I have installed the Revision Control plugin and I set it to do not keep revisions. Any ideea how to do this? I want to keep this format of links.


I took a look again, the permalinks keep their links, but every time I edit it adds a new version to the database and the next post will have a higher number. If I edit my current post for 3 times (blog.rigo.ro/?p=11) the next post will be blog.rigo.ro/?p=14.

Now, my question is how can I keep all my post and edits clean, one post/more edits = one entry in the database, so if I have. 10 post on my site and I edit them, I would like that my permalinks to be from 1 to 10.

PS: I don't want to edit my database manually, is there any plugin to do this?

  • 2
    The simple way is to not use the page ID in your permalink. In my WordPress settings, I can set it to take the title of the page as the permalink. – Randolph West Jun 1 '12 at 3:20
  • @RandolphWest - you should post that as an answer, I think – hircus Jun 1 '12 at 3:27
  • I'm not sure i follow. I've never seen a fresh WP install change id-based slugs on post/page edits. Actually, i've never seen it change ids, ever. Are you sure this isn't being caused by any other plugin? – moraleida Jun 1 '12 at 12:35
  • @moraleida, the way OP describes the behaviour is correct. – user16670 Jun 1 '12 at 21:44
  • @RandolphWest re-read the question, and you're right. At first i thought the same post was having its ids changed from 11 to 14, according to the edits. – moraleida Jun 1 '12 at 22:20

The simple way is to not use the page ID in your permalink.

In my WordPress settings, I can set it to take the title of the page as the permalink. In my example below, I use "Post name".

enter image description here


You'll be able to do it in two steps:

  1. Create one flag value on your database, that will hold the real post-count as an int
  2. Hook to the wp_insert_post_data filter and change the slug as it's generated

The snippet below itercepts every wp_insert_post data call to change the regular slugs to 1+ the last id referenced on the database;

Note that you need to initialize the 'last_post_number' on the db calling update_option at least once before running this.

function wpse_permalink_change($data) {

        // IMPORTANT: before running the code below, check if this is a new post, 
        // or a post edit and discard post edits.

        // Retrieve the last post number saved  
        $i = get_option( 'last_post_number' );

        // Set it as your post_name
        $data['post_name'] = $i;

        // Update the last post number  
        update_option('last_post_number', $i)
        return $data;


This is untested and kinda hackish, but i might dive into making it a plugin if it's of any interest. :)

Also: this only helps if your main concern are the permalinks, no the real database primary_keys.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.