Symptom: Upon enqueuing (in functions.php) a very simple wee bit of jQuery, the console was throwing an error:
‘Uncaught TypeError: $ is not a function’.
So I quickly tried a few of things, just to rule them out:
- first, I confirmed that my file paths for both jQuery & my .js file were correct;
- then I commented out the enqueuing in functions.php and instead loaded my .js file in the header.php,
- then I loaded my .js file in the footer.php,
None of these disappeared the error, so I hit up the interwebs and discovered that WordPress references ‘jQuery’ rather than ‘$’. The simple fix, which I found here is to simply declare jQuery as the $ var:
var $ = jQuery;
Problem solved, coffee still warm.
sr, over & out