Christophe Lacroix
Christophe Lacroix

Reputation: 5

Add css js to a plugin wordpress which call a shortcode

I have to do a wp plugin, it calls a page with a shortcode:

    function shortcode_flexSlide(){
    include ('eleve.php'); 

    }
add_shortcode('flexSlide', 'shortcode_flexSlide');

And now I must load css and js link to the page 'eleve.php'

I have already tried the following:

 wp_enqueue_script( 'flexSlideStyle', plugins_url( '/css/style.css', __FILE__ ));

But it looks at wp root dir + /css/style.css

Upvotes: 0

Views: 418

Answers (1)

Marshal Dudeja
Marshal Dudeja

Reputation: 76

If you want to enqueue stylesheet, please use following syntax.

wp_enqueue_style( 'myCSS', plugins_url( '/css/style.css', __FILE__ ) );

Or you can use something like below:

wp_enqueue_style( 'style-name', get_stylesheet_directory_uri(). '/css/style.css' ); // for css
wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true ); // for script, where 1.0.0 is the version

Hope this helps :)

Upvotes: 1

Related Questions