WordPress.org

Ready to get started?Download WordPress

Forums

Options Framework
[resolved] Output Variables on All Pages (9 posts)

  1. bigmike828
    Member
    Posted 1 year ago #

    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/

  2. bigmike828
    Member
    Posted 1 year ago #

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

  3. Devin Price
    Member
    Plugin Author

    Posted 1 year ago #

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

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

  5. bigmike828
    Member
    Posted 1 year ago #

    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?

  6. bigmike828
    Member
    Posted 1 year ago #

    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?

  7. bigmike828
    Member
    Posted 1 year ago #

    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"; ?>
  8. Devin Price
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  9. bigmike828
    Member
    Posted 1 year ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic