• Resolved bigmike828

    (@bigmike828)


    I am trying to call certain variables on certain pages but the variables are “undefined.”

    For example, I have this code on my header.php file:

    <?php
       $option_one = of_get_option('option_one');
    ?>

    On my sidebar.php page, I have this code:

    <?php
       if(true == of_get_option('option_one')) {
          echo "$option_one";
       }
    ?>

    I have the correct set up within my admin panel (theme options page) because some variables are working while others aren’t.

    Any help would be appreciated!

    http://wordpress.org/extend/plugins/options-framework/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter bigmike828

    (@bigmike828)

    How do I output all of the $options variables from the options framework?

    Plugin Author Devin Price

    (@downstairsdev)

    Do you know the option name? It’s usually set all the top of options.php.

    If so:

    $options = get_option('theme-option-name');
    var_dump($options);
    Thread Starter bigmike828

    (@bigmike828)

    Ok, and if I have multiple options? How would I write that?

    Thread Starter bigmike828

    (@bigmike828)

    When I add your code to the top of my options.php page (and replace ‘theme-option-name’ with my option name), the visual output at the top of my site is “bool(false)”. Does that help narrow down my problem?

    Thread Starter bigmike828

    (@bigmike828)

    So I’m feeling I’m not giving you a whole lot of info…

    In my functions.php file, I have this code:

    if (!function_exists('of_get_option')) {
    	function of_get_option($name, $default = false) {
    		$optionsframework_settings = get_option('optionsframework');
    		$option_name = $optionsframework_settings['id'];
    		if ( get_option($option_name) ) {
    			$options = get_option($option_name);
    		}
    		if ( isset($options[$name]) ) {
    			return $options[$name];
    		} else {
    			return $default;
    		}
    	}
    }

    Do I need to add an include to options.php anywhere on my functions.php page?

    Thread Starter bigmike828

    (@bigmike828)

    Ok, after re-reading the information on your site AND re-watching a few of your videos regarding this framework, I FINALLY saw the line at the top of the Options Framework Theme:

    <?php echo of_get_option('theme-option-name', $default); ?>

    It works. I was originally following someone else’s tutorial that said to output this (which didn’t work):

    <?php echo "$theme-option-name"; ?>

    Plugin Author Devin Price

    (@downstairsdev)

    I’m not quite sure where you’re getting hung up. There’s a ton of example code on the site.

    Try downloading the version on GitHub:
    https://github.com/devinsays/options-framework-plugin

    Copy “Options Check” to your theme directory.

    It has an example of every option, and how to output every option.

    Thread Starter bigmike828

    (@bigmike828)

    I got it fixed. I was using an incorrect way of echoing the variables (thanks to some random tutorial). Once I changed my echo from this…

    <?php echo "$theme-option-name"; ?>

    to this…

    <?php echo of_get_option('theme-option-name'); ?>

    …everything worked perfectly.

    The only place I could find an example of how to echo out the options was by installing the Options Framework Theme. That echo information isn’t anywhere else from what I could see. But anyhow, thanks for the replies and great job on the plugin!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Output Variables on All Pages’ is closed to new replies.