Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom post type that hold real estate listings and I need to figure out a way to keep a record of the price of the property is listed for. For example a user lists a property for sale and then the user edits the property listing and changes the price. I need to show the price before and the new price and the date the price was changed. The price value is stored in a custom field. Doe anyone have any idea of how I can begin to tackle this issue.

I basically need to keep a record of a posts custom field and the date it was changed. If i can get an idea of how to code this I can post the code here for anyone who might find this useful.

Thanks

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

Your best option here is to create a second Custom Field and store an Array of all the versions that have been used together with the date of the update and the user who commited the changes, acually everything you need to know.

Hook into the save_post action and compare the Value of the Custom Field with the last Value of the "HistoryArray". If it is different, push another Element into the Array and update the HistoryArray.

share|improve this answer
1  
I'd add to this solution using an underscore for the second Custom Field (_second_field), so it doesn't shows up in the CF's list. And print the formatted value info in a Custom Meta Box (like the Revisions). –  brasofilo Dec 18 '12 at 17:09
    
yeah, this is a good idea @brasofilo. –  fischi Dec 18 '12 at 19:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.