That should work. Just replace your_post_type
with the name of the post type. Also, little known fact: the save_post
hook passes the post’s ID as an argument.
1 2 3 4 5 6 | function save_my_metadata($ID = false, $post = false) { if($post->post_type != 'your_post_type') return; update_post_meta($ID, 'my_metadata', $_POST['my_metadata']); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.