Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Calling theme-options.php Values WordPress


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

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

Screenshot: [[LINK href=""]][[/LINK]]

<strong>Here's the link to view the code within the theme-options.php file</strong> - [[LINK href=""]][[/LINK]]

Thanks for your help!

Answers (3)


Tobias Nyholm answers:

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


Pippin Williamson answers:

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:

[[LINK href=""]][[/LINK]]

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


Michelle Dancer answers:

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:

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.