• Is there a way to create a conditional in the functions.php to load something if a particular option setting is set from the WP Customizer? This one has got me puzzled beyond belief on how to achieve this.

    Basically I want to enqueue a script for the blog home page based on a theme option setting.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Sure, the code would be structured basically like this:

    add_action('wp_enqueue_scripts', 'enqueue_my_script');
    function enqueue_my_script() {
       if ( $some_value == get_option('option_name')) {
          wp_enqueue_script('my_script', /* the rest of the parameters */);
       }
    }

    Thread Starter Styled Themes

    (@gejay)

    Thanks… I will try that out later today and let you know how it works out.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Conditionals in functions from customizer’ is closed to new replies.