• Brajesh

    (@write2brajesh)


    hi
    I have a plugin which I am using for adding thumbnails for each post.It adds a file type field to the post screen andn when the post is saved/created/published it stores the image file in a folder and does it’s entry in database.

    I am using following actions
    add_action(“publish_post”,’save_post_image’);
    add_action(“wp_insert_post”,’save_post_image’);
    add_action(“save_post”,’save_post_image’);

    and the function save_post_image is written like

    function save_post_image($post_id)
    {
    //perform some action
    }

    Now the real problem is,the $post_id contains the wrong id of the post which is passed by the action hook .
    I wordpress 2.3 and 2.5 it was containing correct post id.
    but in wordpress 2.6 the behavior is strange.If I am creating a post with id=21 then the passed variable contains $post_id=22,I don’t know where is the issue.Please help.

Viewing 1 replies (of 1 total)
  • I’m experiencing the exact same problem.

    When running:

    add_action('save_post', 'function_name');

    Which in turns calls this function:

    function function_name($post_id)
    {
    //perform some action
    }

    The function should be parsed the correct $post_id variable. This only works for the initial save, upon subsequent edits WP passes a different post_id to the post that is being edited.

    If anyone can shed some light on this situation, it would be very much appreciated.

Viewing 1 replies (of 1 total)
  • The topic ‘wp2.6 passing wrong post ids in the functions called by actions publish_post,’ is closed to new replies.