Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

Edit:

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?

share|improve this question
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
add comment

migrated from superuser.com Jun 1 '12 at 7:49

This question came from our site for computer enthusiasts and power users.

2 Answers

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

share|improve this answer
add comment

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' );
        $i++;

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

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

}
add_filter('wp_insert_post_data','wpse_permalink_change',10,2);

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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