I'm using the Options Framework Theme to put together an options page. The user(s) I'm building this for would like to be able to edit a few settings directly from this page, including of which - the Site Title and Tagline.


enter image description here


$options[] = array(
    'name' => __('Site Title', 'options_framework_theme'),
    'desc' => __('The name of your site.', 'options_framework_theme'),
    'id' => 'title',
    'std' => 'PHP CODE FOR SITE TITLE HERE ...',
    'class' => 'medium',
    'type' => 'text');

Is there a way to do this (add their own Site Title and Taglines) within a text-field for example, click the Save Options button to output it to the front-end of the site and display an updated version in the WP API Settings > General Settings sub-menu page?

1 Answer 1


The framework offers a filter for validating input values inside the optionsframework_validate function.
Just for reference, here's the relevant part from the file wp-content/themes/your-theme/inc/options-framework.php:

 * Validate Options.
 * This runs after the submit/reset button has been clicked and
 * validates the inputs.
function optionsframework_validate( $input ) {
/* code */
    $clean[$id] = apply_filters( 'of_sanitize_' . $option['type'], $input[$id], $option );
/* code */

So, considering that we have the following options in the file wp-content/themes/your-theme/options.php:

$options[] = array(
    'name' => __('Input Text Mini', 'options_framework_theme'),
    'desc' => __('A mini text input field.', 'options_framework_theme'),
    'id' => 'blogname',
    'std' => 'Default',
    'class' => 'mini',
    'type' => 'text');

$options[] = array(
    'name' => __('Input Text', 'options_framework_theme'),
    'desc' => __('A text input field.', 'options_framework_theme'),
    'id' => 'blogdescription',
    'std' => 'Default Value',
    'type' => 'text');

And in wp-content/themes/your-theme/functions.php, we filter the text input type (of_sanitize_ + text) and if it matches our defined ids (blogname and blogdescription, just like in General Settings), it will update the site options that have the same id.

Please note, that this doesn't work the other way around: changes made in Settings -> General won't be reflected inside the theme options page...

add_filter( 'of_sanitize_text', 'wpse_77233_framework_to_settings', 10, 2 );

function wpse_77233_framework_to_settings( $input, $option )
    if( 'blogname' == $option['id'] )
        update_option( 'blogname', sanitize_text_field( $input ) );

    if( 'blogdescription' == $option['id'] )
        update_option( 'blogdescription', sanitize_text_field( $input ) );

    return $input;
  • 1
    @user1752759, I've updated the Answer with more details about each block of code. Hope it helps!
    – brasofilo
    Commented Dec 26, 2012 at 5:46
  • Beautiful @brasofilo, just what I was after! Is it also possible to allow this to work the other way too (Settings > General to the Theme Options page)? Commented Dec 26, 2012 at 23:24
  • Possible, it is. I've done it before but cannot find where the code is... Anyway, that's a new, different Question. And a research here at WPSE may bring an answer ;)
    – brasofilo
    Commented Dec 27, 2012 at 10:35
  • Thanks for everything @brasofilo, I'll research and open up a new question for this if needed. All the best. Commented Dec 27, 2012 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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