Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 :)

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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");
    }
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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