The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Default color in style.php

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #180321

    Hi friends I used your tutorial here
    It works I have something like that

    header(“Content-type: text/css; charset: UTF-8”);
    $absolute_path = explode(‘wp-content’, $_SERVER[‘SCRIPT_FILENAME’]);
    $wp_load = $absolute_path[0] . ‘wp-load.php’;
    $bg1 = of_get_option(‘menubg’);
    $bg2 = of_get_option(‘contentbg’);
    Do stuff like connect to WP database and grab user set values

    header(‘Content-type: text/css’);
    header(‘Cache-control: must-revalidate’);
    .menu {
    background:<?php echo $bg1; ?>;
    .content {
    background:<?php echo $bg2; ?>;

    But I want to set a default color if nothing selected in theme settings page and I tried this one but didnt work.

    <?php if(!empty($bg2)) { echo $bg2; } else { echo “#000”; } ?>

    Please can you help me? The comments were closed thankyou


    Maybe try something like this:

    print (isset($bg2)) ? $bg2 : '#000';

    I’m not 100% sure what of_get_option is returning though.


    Too me it seems like a lot of bloat to achieve what you are trying to do.

    Maybe you could set a default color in your css file, then override it with an inline style in your php if an option is selected.


    If this function is from the wordpress options framework plugin, note that the function signature looks like:


    …which implies (I haven’t checked) that you can simply pass a default value when you call the function in the first place.

    $bg2 = of_get_option( 'contentbg','#000' );
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Back End’ is closed to new topics and replies.