Support » Fixing WordPress » Post revisions

  • Resolved Ingoal


    Hi there, I just upgraded all my blogs from 2.5.1 to 2.6. Right after the upgrade I noticed something strange. I’ve got a custom plugin running that generates a shorturl (using and posts a tweet containing a short line + posttitle + shorturl to twitter (using the API). All good there.

    BUT, there’s always a but now isn’t there, each new post results in more than one tweet. Why? Because of the post-revisions. So, can someone tell me how I can easily check the status of a post at POST-time, so that only the “published” ones are used by the script and the revisions (‘inherited’) are ignore?

    Any help would be appreciated.

Viewing 15 replies - 1 through 15 (of 15 total)
  • Anyone?

    Come on ppl…what’s up with this support forum…everytime I post something on here there’s a big blank…are my problems really that strange? Sigh…

    I am having the same problem with a plugin of mine, must be others out there too. Fixing it right now.

    The problem is that your plugin probably saves the posts ID somewhere. However, after a revision the ID is changed, that is, a new post row is created and the old one (with the old ID) is set to post_type = ‘revision’.

    Why not search and find out on the forum?

    You can turn off revisions as suggested through the above article.

    microkid: yeah, that sounds about right…need to check post-id handling again…

    hotkee: Because turning it off is bs…plain and simple, I can’t tell ppl “turn off revisions, because else my plugin won’t work”…apart from the fact that it can have side-effects to disable it (see šŸ˜‰

    No that’s definitely not an option. It has to be plug and play.

    I’m looking into it right now, trying to find a hook that will let us update our plugin data when the post is saved. I’ll let you know here when I find the solutions, because it’s out there šŸ˜‰

    I was wrong, the ID is not changed, but when saving the post the save_post hook is called twice: once when saving the post before editing as a revision, once for saving the current version. Seems like that’s our problem right there.

    I have found a solution by using this in whatever function you call with the save_post hook:

    function plugin_function_save_postdata($post_id)
     if(wp_is_post_revision($post_id) || wp_is_post_autosave($post_id))
       return $post_id;
      // your process that uses $post_id

    This way, the process is not run for the revision.

    Microkid: That should do it! Thanks a lot…I’ll keep you posted on my progress in fixing my plugin…just watch twitter šŸ˜‰



    Hey microkid, thanks for directing me here but I’m a little lost as to how I can implement your fix? >_<

    Like which file to edit…?

    I thought you were having truoble with a plugin, since you were talking about problems with shifting ID’s.

    Me and Ingoal both have plugins that take the ID of a post when it’s saved through the save_post hook. With the revision system, this hook is called not only for the actual post, but also for the revision. So we had double entries show up. The fix mentioned above is to be placed in the function of your plugin that is called by save_post.

    So is it a plugin that’s causing you trouble?



    Oh nope lol. Nothing to do with plugins. I just want my Post IDs to stop jumping everytime I edit a post. It seems that even with some of the “anti-post-revisions” plugins and methods installed, the IDs still jump anyway.

    Ah šŸ™‚ Well, don’t be bothered by ID’s – they’re just references. You should use pretty permalinks anyway šŸ™‚



    Haha…I happened to be the 1% who’s not a fan of pretty permalinks. ^^” Most of my post titles are in Japanese anyway…that’s why. >_< Anyhow! I found a plugin that solved my ID problem! Just plugging it here for anyone who needs it.

    Just dropping by to say thanks, a big thank. I was having the same issue after upgrading to 2.6 with a plugin of mine and was wondering what was going wrong. Just fixed it with you advices and it’s working great. NĀ°1.

    I restarted blogging once again and migrated everything today(wp 2.7.1) and I wanted to say that I agree with fantasycrusader. I also like my posts ID to go in chronological order. šŸ™‚

    Many thanks

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Post revisions’ is closed to new replies.