[wp-hackers] Access to Previous Post Content

Bill Smith ml_wordpress at copperleaf.org
Fri May 11 14:17:01 GMT 2007


Bill Smith wrote:
> Hi,
>
> I'm trying to get access to the previous content of an updated post. 
> In other words, if a post is being updated, I'd like a chance to query 
> the old post content *before* the new content is written. I've looked 
> at the save_post action, but obviously that occurs after the post has 
> been updated. Looking at the source for the wp_insert_post function, 
> none of the filters that are called will give me the post id. Is there 
> a way to do this? I thought about creating a query based on the slug 
> which I can get with the name_save_pre filter, but not sure if that's 
> the best way.
>
> Bill 
Shortly after I sent this I realized that querying by slug wasn't going 
to work because the slug could be different. To get it to work, I 
registered a content_save_pre filter and grabbed the $_POST['post_ID'] 
value if it's set. Obviously if it isn't set, there is no previous 
content to find. I'm still not sure though if this is the best route. 
Would a save_post_pre action make more sense?

Bill


More information about the wp-hackers mailing list