Support » Alpha/Beta/RC » problems returning options value

  • Resolved cybershot


    I made a meta box for post and pages that has one text input option for a description. The database updates fine, I can see the option and value in the database. I can get the option and return it to the page just fine doing this

    $options = get_option(‘description’);
    echo $options

    My problem is that I am trying to populate the form in the admin the same way but I get nothing.

    $options = get_option('description');
       echo '<label for="page_post_description">' . __("Description Text: ",'page_description_textdomain') . '</label><br /><br />';
       echo '<input type="text" class="widefat" id="page_post_description" name="description" value="' .  $options . '" />';

    What am I missing?

Viewing 1 replies (of 1 total)
  • Moderator Andrew Nacin


    Lead Developer

    Not sure, but one thing you’re missing is an esc_attr() around $options, in order to properly escape the attribute value.

    This has two purposes. One, it closes a potential XSS vulnerability vector. Two, if you have single or double quotes, ampersands, or angle brackets in your description, this properly encodes them, rather than breaking your HTML.

Viewing 1 replies (of 1 total)
  • The topic ‘problems returning options value’ is closed to new replies.