Tag Info

Hot answers tagged

1

The "Failed to load resource" is probably a red herring and isn't related to your issue. The fact that it is throwing an error about the $ shortcut means your js file is being loaded correctly. The likely issue is that jQuery in WordPress loads in "noConflict" mode. As such the $ shortcut will not work by default. Try replacing your script with this: ...


1

This is how you would use the user_register hook to load your script: add_action( 'user_register', 'new_user_tracking_script' ) function new_user_tracking_script(){ // Google Analytics wp_enqueue_script( 'new_user_tracking' ); }


1

Prioritize your actions, so the register_style function runs first. (notice the third parameter in the add_action function) add_action( 'wp_enqueue_scripts', 'other_register_styles', 11 ); function other_register_styles() { wp_register_style( 'style', PATH . 'assets/css/style.min.css' ); wp_enqueue_style( 'style' ); // Working as expected ...


1

The earliest safe hook to get post information is the template_redirect hook. All the hooks in question runs before Wordpress has setup postdata, so any post info are still unavailable at that point. The globals like $wp_query and $post will still contain no data, that is why your efforts returns nothing. EDIT Extra info as per comment by @TheDeadMedic ...



Only top voted, non community-wiki answers of a minimum length are eligible