I’m trying to include my plugin stylesheet on my WP website (frontend), but for some reason it’s not working.
function init_gallery_scripts() {
if (is_admin() ) {
// This works!
wp_enqueue_script('gallery', plugins_url('js/gallery.js',__FILE__),array('wp-filebrowser'));
wp_enqueue_style('gallery-css', plugins_url('style/gallery.css',__FILE__));
}
else {
// This is not woking. Why?
wp_enqueue_style('gallery-front-css', plugins_url('style/gallery_front.css',__FILE__));
}
}
I’ve also tried this with no success:
wp_register_style('gallery-front-css', plugins_url('style/gallery_front.css',__FILE__));
wp_enqueue_style('gallery-front-css');
Not sure what I’m doing wrong here.
Thanks to awats, I found my “stupid” error.
The
add_action()
command was set to initiate onadmin_init
, thus never getting triggered in frontend (because you are not backend in admin section).Changing this to trigger on
init
solved the issue.