I am trying to use css and js in a wordpress plugin I developed. I looked into the codex and I know I have to use wp_enqueue_script to add js, and wp_enqueue_style to add css with plugins_url to output the correct path, but I can’t figure out how to do it. I have a file structure so that it’s the plugin then plugin > css and plugin > js where css and js are folders that contain their respective files.
I tried doing:
function my_scripts_method() {
wp_enqueue_script('js/tabpane.js');
wp_enqueue_script('local/helptip.js');
wp_enqueue_script('local/webfxapi.js');
wp_enqueue_script('local/webfxlayout.js');
}
add_action('wp_enqueue_scripts', 'my_scripts_method'); // For use on the Front end (ie. Theme)
but it’s not working at all, and the codex isn’t of much more help. Could anyone let me know what I’m missing?
When adding files to backend plugins you need to do a few things within your code:
Or you could use just the add_action(‘init’, ‘your_code_for_enqueue’);