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 need to add a 'poll' to every single post automatically, and wish to do this without having to manually create a poll each time using a plugin, so I had an idea to store the poll results as meta data in the post. So each time someone votes, it saves their vote as a custom field meta value in the post.

This should work in theory, however one problem I've discovered early on is that when editing the post which contains a poll, if someone votes while I am editing and then I press Update, the results are reset back to whatever they were before I started editing, because the custom field is being saved along with the post.

Is there any way to stop a certain custom field from being saved when I update a post? Or to make it retrieve the latest value before saving it?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I would recommend you to remove custom fields meta box from the post editing page. You can do it by using remove_meta_box() function.

add_action( 'admin_menu' , 'wpse8170_remove_post_custom_fields' );
function wpse8170_remove_post_custom_fields() {
    remove_meta_box( 'postcustom' , 'post' , 'normal' ); 
}
share|improve this answer
    
Great thanks, I ended up hiding it using the custom field code, but this works as well. –  Shaun Aug 9 '13 at 14:36

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.