logo

$20
Calling theme-options.php Values

Attached is the theme-options.php file I am using for my custom theme...

How do I call the saved values into my theme's template so I may display them?

Screenshot: http://i51.tinypic.com/vo1lzd.png

Here's the link to view the code within the theme-options.php file - http://tinypaste.com/d8edb

Thanks for your help!

Spencer Barfuss | 09/05/10 at 9:15pm | Edit


(3) Possible Answers Submitted...

  • avatar
    Last edited:
    09/05/10
    10:00pm
    Pippin Williamson says:

    This isn't something you can do in just a few line of code, but you can just follow this tremendous tutorial on Net.Tuts:

    http://net.tutsplus.com/tutorials/wordpress/how-to-create-a-better-wordpress-options-panel/

    It's the article that I used the first time I built an options page and it worked wonders for me.

  • avatar
    Last edited:
    09/05/10
    11:33pm
    Michelle Dancer says:

    I'm assuming the options are already being successfully saved to the database, from the way you describe it, if not let me know.

    To use them within your theme template files you'll first need to put the following code at the very start of the file in question:

    <?php
    global $options;
    foreach ($options as $value) {
    if (get_settings( $value['id'] ) === FALSE) {
    $$value['id'] = $value['std'];
    } else {
    $$value['id'] = get_settings( $value['id'] );
    }
    }
    ?>


    That's basically it, now your options are all accessed through their own variable, depending on how you've named them. For example to find the value of the slider title option, if it was saved to the database as spencer_slider_title, you would use $spencer_slider_title.

  • avatar
    Last edited:
    09/06/10
    12:27am
    Tobias Nyholm says:


    echo "The 'Slider Title is: ';
    $options = get_option( 'sample_theme_options' );
    echo $options['sometext11'];

This question has expired.





Current status of this question: Completed