• With 2.6, I ran into some issues with a plugin I am creating which saves its data with in the post meta. The problem is the revision system because my plugin is passed the revision ID (not the post ID) when the post is saved. Here is the code snippet I found to translate the revision ID to the post ID.

    // saving
    if ($the_post = wp_is_post_revision($post_id)){
       $post_id = $the_post;
    }
    add_post_meta($post_id, $key, $value, true) or update_post_meta($post_id, $key, $value);
    // retrieving
    if ($the_post = wp_is_post_revision($post_id)){
       $post_id = $the_post;
    }
    get_post_meta($post_id, $key, true);

    It would be great if this part of the API is updated to give control regarding the revisions.

The topic ‘[Learned Lesson] Plugin adding using meta on a post and revisions’ is closed to new replies.