Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have some relatively complex and costly code which extracts details of images from a JAlbum album, and displays that info with relevant posts. This currently runs every time the post is displayed, and works fine.

I want to cache this data as post metadata, so that in appropriate circumstances I just use the cached data and save on a lot of processing time. I have the following code which is called as part of my processing loop, which I expected to save the values back to the relevant post:

update_post_meta($imagePostID, 'slideDate', $slideDate);
update_post_meta($imagePostID, 'imagePath', $imagePath);
update_post_meta($imagePostID, 'imageMeta', $imageMeta);

The problem is that it's not saving the values. I suspect that this is because it's not in the context of a "save" event. Is there something else I need to do to save these changes on the fly?

share|improve this question
1  
how do you know that the values are not saved? You should provide as much code as possible if you want people to be able to help you. when exactly are you updating the meta data and how do you retrieve it? – Mark Kaplun Mar 6 at 9:01
Hi The values are definitely not saved - the revised meta data is not visible via the post editor or by inspecting the database. I have a plugin which retrieves the data within the loop for every post. After processing this data I am trying to save the calculated values using the code above. What else do you need to know? Thanks Andrew – user28461 Mar 6 at 22:02

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.