我需要第二双眼睛,因为太晚了,我再也看不见了。
为什么这个不能保存?我错过了什么?
add_action("admin_menu", "tf_book_stuff_create");
function tf_book_stuff_create(){
add_meta_box(\'tf_book_stuff\', \'Book Stuff\', \'tf_book_stuff\', \'books\');
}
function tf_book_stuff() {
global $post;
$custom = get_post_custom($post->ID);
$tf_book_number = $custom["tf_book_number"][0];
$tf_book_reader = $custom["tf_book_reader"][0];
echo $tf_book_isbn;
echo $tf_book_level;
?>
<div class="admin_meta">
<ul>
<li><label>Book ISBN:</label><input name="tf_book_number" value="<?php echo $tf_book_number; ?>" /></li>
<li><label>Reading Level:</label><input name="tf_book_reader" value="<?php echo $tf_book_reader; ?>" /></li>
</ul>
</div>
<?php }
add_action("admin_menu", "save_tf_book_stuff");
function save_tf_book_stuff($post_id) {
global $post;
update_post_meta($post->ID, "tf_book_number", $_POST["tf_book_number"]);
update_post_meta($post->ID, "tf_book_reader", $_POST["tf_book_reader"]);
}
谢谢
SO网友:Nadine
哦,我找到了。这可能有点倒退(我确信有更简短、更好的方法),但它确实有效。
function save_tf_book_stuff() {
global $post;
$custom = get_post_custom($post->ID);
update_post_meta($post->ID, "tf_book_number", $_POST["tf_book_number"]);
update_post_meta($post->ID, "tf_book_reader", $_POST["tf_book_reader"]);
}