Need help with adding jQuery script to WP and calling script to page

i usally first deregister to avoid duplicates, then register it and enqueue it like so: function my_scripts_method() { wp_deregister_script( ‘jquery’ ); wp_register_script( ‘jquery’, ‘http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js’); wp_enqueue_script( ‘jquery’ ); } add_action(‘wp_enqueue_scripts’, ‘my_scripts_method’); Hope this helps, Sagive.

wp_enqueue doesn’t load dependencies

You have to define the dependencies for either styles or scripts when you register them. Or, if you’re avoiding the registration completely, then it’s ok to stuff them into the queueing process. See more on the Codex page. wp_register_style( ‘reset’, get_template_directory_uri().’/reset.css’ ); wp_register_style( ‘style’, get_template_directory_uri().’/style.css’, array( ‘reset’ ) ); wp_enqueue_style( ‘style’ ); Also avoid single … Read more

JS plugin script loading but not working

WordPress-specific script issues are generally limited to one of the following: Improperly enqueued script Proper script enqueueing involves use of wp_enqueue_script(). If the script is properly enqueued, you will see a <script….> link in the document head or footer Not accounting for jQuery no-conflict mode WordPress-bundled jQuery is configured for no-conflict mode, which requires wrapping … Read more

can’t access dashboard and showing forbidden page

Here is the short sweet answer. Somewhere you, a plugin, or your theme are doing something like this: wp_register_script( ‘myscript’, get_template_directory_uri() . ‘/path/to/myscript.js’, ”, ”, true ); What should be happening is this: add_action( ‘wp_enqueue_scripts’, function() { wp_register_script( ‘myscript’, get_template_directory_uri() . ‘/path/to/myscript.js’, ”, ”, true ); } ); From the Notice: Scripts and styles should … Read more

How to get, in WP page’s script, a wp enqueued script (in Functions.php)?

You have to make sure your script is registered with wp_register_script before your call to wp_localize_script. So in your functions.php file: add_action(‘init’,’my demo_function’); function my demo_function() { // Register the script wp_register_script( ‘myuserscript’, ‘path/to/myscript.js’ ); // Localize the script with your data $theid=get_current_user_id(); $params = array( ‘userid’ => $theid ); wp_localize_script( ‘myuserscript’, ‘MyUserParams’, $params ); … Read more

How to redirect new registrars to a custom registration page instead of WP default registration page?

Since wp-login.php control both login and registration, it is better to redirect the visitor to a login page from wp-login.php. You can use this code for redirecting your registration page – add_action(‘init’,’custom_registration_page’); function custom_registration_page() { $new_registration_page_url = home_url( ‘/register/’ ); global $pagenow; if( $pagenow == “wp-login.php?action=register” && $_SERVER[‘REQUEST_METHOD’] == ‘GET’) { wp_redirect($new_registration_page_url); exit; } } … Read more