Support » Themes and Templates » Problem accessing stored options from style.php

  • Jeremy Clark



    Here’s the background, I have a theme I’m writing, and I want to use an external style.php file instead of having styles in the header plus I’ve set the file where it will be cached by the browser. The code that I’ve been using to access the variables where I’ve set the theme options works all other theme pages but not the style.php. This is the code the pull the options from the wp_options table in the database.

    global $options;
    foreach ($options as $value) {
    if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; }
    else { $$value['id'] = get_settings( $value['id'] ); } } ?>

    To get this to work in the style.php file I’ve had to use this code which I really don’t want to use.

    if (file_exists(dirname(__FILE__) . '/../../../wp-load.php')) {
    include_once dirname(__FILE__) . '/../../../wp-load.php';
    // load from DB
    } elseif (file_exists(dirname(__FILE__) . '/../../../../wp-load.php')) {
    include_once dirname(__FILE__) . '/../../../../wp-load.php';
    // load from DB

    It had been suggested to use the query_vars hook but I’m not sure where to even start with that.

  • The topic ‘Problem accessing stored options from style.php’ is closed to new replies.