WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need a second set of eyes, because its late and I can't see this anymore.

Why won't this save? What am I missing?

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"> 
        <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>
<?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"]);


share|improve this question
Isn't this a duplicate of wordpress.stackexchange.com/questions/65000/… ? Are you having further problems? – helgatheviking Sep 13 '12 at 20:33
Kind of different, same vein. I usually have meta-box issues of some kind. Mostly I just forget something. In this case, one line. – Nadine Sep 13 '12 at 21:30
Ok, but the code I provided there should have been saving properly. As I posted on your other question, $post_id is passed as a parameter to your save_tf_book_stuff($post_id) function. – helgatheviking Sep 13 '12 at 21:38

Instead of using the global $post variable, try just using the $post_id that was passed to the function in the first place.

update_post_meta($post_id "tf_book_number", $_POST["tf_book_number"]);
update_post_meta($post_id, "tf_book_reader", $_POST["tf_book_reader"]);
share|improve this answer
Hmm. That didn't work. Maybe there's another way to code said meta box. – Nadine Sep 13 '12 at 17:50
I'm sorry, I don't see anything wrong with your code. – Douglas.Sesar Sep 13 '12 at 18:08
S'okay, found a solution. Thank you for the response though. – Nadine Sep 13 '12 at 21:23

Oh I found it. Its probably a little backwards (ie I'm sure there are shorter nicer ways to do it), but it works.

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"]);


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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