1

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?

1 Answer 1

2

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' ); 
}
1
  • Great thanks, I ended up hiding it using the custom field code, but this works as well.
    – Shaun
    Commented Aug 9, 2013 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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