2

I'm trying to us get_option in my plugin to choose to load 1 of 3 js files.

I started with this (and it works) ...

add_action('wp_footer','isotope_vpl_set_style');

function isotope_vpl_set_style() {
        include("inc/myfile.js");
        }

then I changed it to ...

add_action('wp_footer','isotope_vpl_set_style');  

function isotope_vpl_set_style() {   
$style = (get_option('damien_style');    
if  $style = ("isotope"){
        include("inc/myfile.js");
        }
}

And it's not working ... I checked the SQL table and the option name and value are set.

My PHP error log tells me I have an unexpected ; on this line $style = (get_option('damien_style');

Where have I gone wrong please :)

1

You had an extra ( before get_option and the if statement syntax was wrong. Here is the revised code:

add_action('wp_footer','isotope_vpl_set_style');  

function isotope_vpl_set_style() {   
    $style = get_option('damien_style');    
    if($style == "isotope") {
        include("inc/myfile.js");
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.