Support » Fixing WordPress » Post Status and Post Meta Data

  • Resolved TwoThirdsWater


    I’m working on a post-expires plugin, adapted from the atropos plugin.

    I’ve noticed that when the posts status is updated (from draft to published or visa-versa), the meta data I have saved against the post is lost (or loses its connection to the post). This is first time I’ve used meta-data at all (I’m usually a custom field kind guy) and don’t know enough about how the meta relationships are formed. Please could someone advise me how to maintain the connection when the post status changes.

    Thank you!

    p.s. For those interested, the primary change I am making to atropos is to set expired posts status to “draft’ rather than deleting the post.

Viewing 3 replies - 1 through 3 (of 3 total)

    Post meta data are nothing but some information related to the post…, so it does not change even if you change the post status(at least it should not)..

    For saving additional informtion, you should always use custom fields. Changing the post status does not change the relation between a post and custom fields..

    Use this function to update the existing post:


    Thanks Rahul.

    I’ve made a bit of progress, reading the link you sent me I adapted the code further to use the functions:

    This has partly solved the problem in that if I change the status of the post via the main post edit screen. The meta data is maintained, but if I do it via the quick-edit on the post list then the meta data is lost!

    I imagined that the code called would be the same for both of these processes, but clearly something different is going on!

    Ah… solved my own problem.

    It seems the issue was the logic within the plugin when the post was saved. On the post edit screen the meta value was in place. On the quick edit, the post meta values were not there so the value was deleted by the plugin. I’ve put in a control now that stops this issue.

    Thanks for your help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Post Status and Post Meta Data’ is closed to new replies.