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

Calling theme-options.php Values WordPress

  • SOLVED

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="http://i51.tinypic.com/vo1lzd.png"]]http://i51.tinypic.com/vo1lzd.png[[/LINK]]

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

Thanks for your help!

Answers (3)

2010-09-06

Tobias Nyholm answers:


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

2010-09-05

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="http://net.tutsplus.com/tutorials/wordpress/how-to-create-a-better-wordpress-options-panel/"]]http://net.tutsplus.com/tutorials/wordpress/how-to-create-a-better-wordpress-options-panel/[[/LINK]]

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

2010-09-05

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:

<?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.