1
votes

I developed a wordpress theme and it's working fine. Not until I discovered that some plugins are not working well with the theme due to the fact that the theme cannot import the styles and scripts of the plugins. So is there any code that can automatically enqueue any wordpress plugin script or style in my theme. I've read almost everything about wp_enqueue_script but I still can't get it working. Any help will be appreciated.

Thank you. Ossai Emmanuel C

2
You can add the necessary code to your theme's functions.php - j08691

2 Answers

1
votes

Some plugins load their scripts into the footer instead of the <head>. Make sure your theme also contains this...

<?php
   /* Always have wp_footer() just before the closing </body>
    * tag of your theme, or you will break many plugins, which
    * generally use this hook to reference JavaScript files.
    */
    wp_footer();
?>
</body>
</html>

That's a direct quote from https://codex.wordpress.org/Function_Reference/wp_footer

0
votes

You probably need to call wp_head() at the bottom of the <head></head> section of your theme. Plugins hook onto the wp_head action to add their scripts and styles using wp_enqueue_script() and wp_enqueue_style(). wp_head() basically triggers the wp_head action. So just add wp_head() like this:

<html>
    <head>
        <!-- Your meta tags here -->
        <?php wp_head(); ?>
    </head>
    <body>
        <!-- Your html here -->
    </body>
</html>

Here is a reference on wp_head: https://codex.wordpress.org/Plugin_API/Action_Reference/wp_head