• Resolved JonathanAlphonso

    (@jonathanalphonso)


    Hi everyone,

    I am having some trouble setting defaults in Options Framework for my wordpress theme. When you install the theme I want my default values, which I’ve set in options.php using the ‘std’ key, to appear on the wordpress site when the theme is installed.

    When I go to theme options, I see the defaults values I set, but they don’t appear until I click the “Save Options” button in the Theme Options tab.

    You can see my dev site before, this is a fresh site with the theme installed and nothing else. I want to make it so that it will show the defaults on a fresh install.


    http://tests.jalphonso.com/wp/

Viewing 3 replies - 16 through 18 (of 18 total)
  • Thread Starter JonathanAlphonso

    (@jonathanalphonso)

    OK, getting ready to launch my theme!

    One pretty important note though…

    The function for getting defaults is located in funtions.php, so you have to include options.php in the of_get_default function.

    For example, this will render your WP install unusable

    require_once('options.php');
    function of_get_default( $option ) {
         $defaults = optionsframework_options();
         if ( isset( $defaults[$option]['std'] ) ) {
              return $defaults[$option]['std'];
         }
         return false; // default if no std is set
    }

    What you need to put is this:

    function of_get_default( $option ) {
         require_once('options.php');
         $defaults = optionsframework_options();
         if ( isset( $defaults[$option]['std'] ) ) {
              return $defaults[$option]['std'];
         }
         return false; // default if no std is set
    }

    Just worked this out and didn’t want anyone else to make the same mistake

    Hi @jonathanalphonso. It would be better require options.php from your functions file on theme setup. Then it’s available to the function every time its called.

    Thread Starter JonathanAlphonso

    (@jonathanalphonso)

    Hmmm, I used to have the require_once(‘options.php’); outside of the function alongside the rest of the require_once commands. But this broke the site giving me this error:

    Fatal error: Call to undefined function wp_reset_vars() in C:\xampp\htdocs\wordpress\wp-admin\options.php on line 25

Viewing 3 replies - 16 through 18 (of 18 total)

The topic ‘Defaults while using Options Framework’ is closed to new replies.