Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
add_meta_box()で追加したUIで保存したカスタムフィールドのデータが消えるのを防ぐ
<?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
You can’t perform that action at this time.