I've added wp_enqueue_media() to a specific page (before including the header) on my custom theme but it flat out will not any of the JS on the page.
I've already done the basic troubleshooting:
- Deactivated all plugins (no go)
- changed themes to twenty sixteen, this time leaving all the plugins activated, and added wp_enqueue_media() function to the page.php template (that works)
- moved the function to the wp_head (still doesnt work)
- commented out everything from my functions file (thus stopping any of my JS,styles, and hooks from being loaded - but this also doesn't work)
- Cleaned the DB and did a fresh install (doesn't work)
so steps 1 and 2 rules out plugin conflicts, and 4 should rule out something in my functions file. I dont know where to go from here.
note - In my functions file, I was unregistering jquery to use a different version. When I did that, nothing loaded with the wp_enqueue_media function. But when I commented out that line I was able to get a few more scripts:
jquery.js?ver=1.12.3
jquery-migrate.min.js?ver=1.4.0
plupload.full.min.js?ver=2.1.8
wp_enqueue_media()
? This is only meant to load media JS API scripts, styles and markup. What JavaScript files are we talking about? Why are you not usingwp_enqueue_script()
?This function should be called from the 'admin_enqueue_scripts' action hook, or later.
Make sure that all requirements are met, here's more information about it.