Support » Themes and Templates » How to call options from theme options to display in theme.

  • Resolved cnrcssl

    (@cnrcssl)


    I have installed this http://wptheming.com/options-framework-theme/ on my theme i am making.

    How would i go about making a text box option show up in a div on my homepage?

    Currently my code looks like this

    <?php $options = get_option( ‘options_framework_theme’ ); ?>
    <?php echo $options[‘example_textarea’] ?>

    example_textarea is the id of the option from the framework.

    Any ideas thoroughly appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Chip Bennett

    (@chipbennett)

    Theme Review Admin

    What does that code give you?

    If not what you expect, then what does the following produce:

    $options = get_option( 'options_framework_theme' );
    var_dump( $options );

    My current code gets me nothing.

    Just included it as a starting point really.

    The code you included produces this

    bool(false)

    Thanks for your help.

    Chip Bennett

    (@chipbennett)

    Theme Review Admin

    The code you included produces this

    bool(false)

    That means that there is no such option 'options_framework_theme' in the database.

    Is that the actual name of your Theme options? If not, what is the actual name? If so, have your saved your Theme options?

    Ah ok.

    I have just included the default http://wptheming.com/options-framework-theme/

    in an effort to try and understand how it all works.

    Changing the code to

    $options = get_option( ‘optionsframework’ );
    var_dump( $options );

    produces this

    array(3) { [“id”]=> string(9) “wordpress” [“knownoptions”]=> array(1) { [0]=> string(9) “wordpress” } [“version”]=> string(3) “1.5” }

    This is a copy of the first part of the options.php

    <?php
    /**
    * A unique identifier is defined to store the options in the database and reference them from the theme.
    * By default it uses the theme name, in lowercase and without spaces, but this can be changed if needed.
    * If the identifier changes, it’ll appear as if the options have been reset.
    */

    function optionsframework_option_name() {

    // This gets the theme name from the stylesheet
    $themename = get_option( ‘stylesheet’ );
    $themename = preg_replace(“/\W/”, “_”, strtolower($themename) );

    $optionsframework_settings = get_option( ‘optionsframework’ );
    $optionsframework_settings[‘id’] = $themename;
    update_option( ‘optionsframework’, $optionsframework_settings );
    }

    How do i tell what the actual name of my theme options is?

    Thanks

    I managed to find the solution. The options framework appears to use the name of the Theme directory folder rather than the name specified in the CSS file. All working fine now.

    thanks Chip for your help!

    Chip Bennett

    (@chipbennett)

    Theme Review Admin

    Fantastic!

    (Please be sure to mark the topic as “Resolved”, so others know that the issue is resolved.)

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to call options from theme options to display in theme.’ is closed to new replies.