I use

<?php if ( get_option('mytheme_slider') == 'checked') { get_template_part( 'partials/slider/slider-java-script' ); } ?>

to include the slider-java-script.php template part into my site. Works fine.

How can i include or load my slider-java-script.css file if the same option is checked?


Add a function to your functions.php file like this:

function slider_scripts() {
    wp_enqueue_style( 'slider-java-script', get_template_directory_uri() . '/css/slider-java-script.css' ); //change the location to work for you

Then add slider_scripts() to the top of the template part ( partials/slider/slider-java-script.php )

| improve this answer | |

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.