Jquery function working in Dev Console but not otherwise [duplicate]

As toscho pointed out, use jQuery(document).ready(function($) { … }); instead of $( function() { … }); Edit: Main problem is WP rich text editor escaping your html <script> tags. See https://codex.wordpress.org/Using_Javascript at the bottom of the page for a plugin-based workaround to turn off formating for specific posts/pages, allowing you to insert code. Alternately, add … Read more

Where is the right place to register/enqueue scripts & styles

Why registering and queuing properly matters it should be in time – earlier than script/style is up for being output to page, otherwise it is too late; it should be conditional – otherwise you are loading stuff where you don’t need it and cause performance and functionality issues, for this you need WP environment loaded … Read more

include script that depends on modernizr?

I assume these are child theme scripts because of your function name: twentyfourteen_child_scripts() When loading scripts from your child themes functions file you should use: wp_enqueue_script( ‘$handle’, get_bloginfo( ‘stylesheet_directory’ ) . ‘/js/filename.js’, array( ‘jquery’ ), ‘1.0.0’ ); Or use add_action( ‘wp_enqueue_scripts’, ‘child_add_modernizr_scripts’ ); function child_add_modernizr_scripts() { wp_register_script(‘modernizr’, get_stylesheet_directory_uri() . ‘/js/modernizr.js’, false, ‘1.0’, true ); wp_enqueue_script( … Read more

How to call wp_localize_script() after the script?

Well, you have to call wp_licalize_script after registering the script, because you need handle of that script… And of course you can’t localize something that doesn’t exist… Here’s some example: if ( !function_exists(‘pt_scripts’) ): function pt_scripts () { wp_register_style( ‘style’, get_stylesheet_uri(), null, ‘1.3.1’, ‘all’ ); wp_enqueue_style( ‘style’ ); wp_register_script( ‘scripts’, get_template_directory_uri() . ‘/script.js’, array(‘jquery’), ‘1.3.0’, … Read more