WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to call options from theme options to display in theme. (7 posts)

  1. cnrcssl
    Member
    Posted 1 year ago #

    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.

  2. Chip Bennett
    Theme Review Admin
    Posted 1 year ago #

    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 );
  3. cnrcssl
    Member
    Posted 1 year ago #

    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.

  4. Chip Bennett
    Theme Review Admin
    Posted 1 year ago #

    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?

  5. cnrcssl
    Member
    Posted 1 year ago #

    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

  6. cnrcssl
    Member
    Posted 1 year ago #

    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!

  7. Chip Bennett
    Theme Review Admin
    Posted 1 year ago #

    Fantastic!

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

Topic Closed

This topic has been closed to new replies.

About this Topic