Give help. Get help.

  • # August 22, 2014 at 2:58 pm

    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

    # August 22, 2014 at 5:40 pm

    Maybe try something like this:

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

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

    # August 22, 2014 at 5:50 pm

    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.

    # August 22, 2014 at 6:30 pm

    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)

You must be logged in to reply to this topic.