Created
February 17, 2014 10:29
-
-
Save miya0001/9048229 to your computer and use it in GitHub Desktop.
add_meta_box()で追加したUIで保存したカスタムフィールドのデータが消えるのを防ぐ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action("save_post", "save_post_meta"); | |
function save_post_meta($id) | |
{ | |
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { // オートセーブの時は何もしない | |
return $id; | |
} | |
if (isset($_POST['action']) && $_POST['action'] == 'inline-save') { // クイックポストの時は何もしない | |
return $id; | |
} | |
if (isset($_POST['featured']) && $_POST['featured']) { | |
update_post_meta($id, '_featured', $_POST['featured_order']); | |
} else { | |
delete_post_meta($id, '_featured'); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment