Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i have used the tutorial of add metabox . but my data does not save in the box . ihave the meta box in edit link page , but when i put any data in the box and press update button it dont save the data.

Then actually i want to know when i put the data in the box can i get the data by using $_POST[] ? if yes, plz help me so me error part of my code..

// backwards compatible

add_action( 'admin_init', 'blc_add_custom_link_box', 1 );



/* Do something with the data entered */

add_action( 'save_link', 'blc_save_linkdata' );



/* Adds a box to the main column on the Post and Page edit screens */

function blc_add_custom_link_box() {

    add_meta_box( 

        'backlinkdiv',

        'Backlink URL',

        'blc_backlink_url_input',

        'link',

        'normal',

        'high'

    );

}

/* Prints the box content */

function blc_backlink_url_input( $link ) {

  // Use nonce for verification

  wp_nonce_field( plugin_basename( __FILE__ ), 'blc_noncename' );



#  if(get_option( "backlink_url" ) != $_POST['backlink_url']) {

#    update_option( "backlink_url", $_POST['backlink_url']);

#  }

  ?>

  <input type="text" id="backlink-url" name="backlink_url" value="<?php echo get_option('backlink_url'); ?>" size="60"/>
  <?php



}

/* When the link is saved, saves our custom link data */

function blc_save_linkdata( $link_id ) {

  // verify if this is an auto save routine. 

  // If it is our form has not been submitted, so we dont want to do anything

#if (!defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {

#    return $link_id;

#    

#    }



     if( isset( $_POST['backlink_url'] ) ){ 

        update_option( $link_id, "backlink_url", $_POST['backlink_url'] );

    }

Now i want to save the data in the box that may not save in data base. So how the data from meta box save . Plz help me..

share|improve this question
add comment

1 Answer

There is no save_link action. save_linksave_post

Final code should look like this add_action( 'save_post', 'blc_save_linkdata' );

share|improve this answer
add comment

Your Answer

 
discard

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.