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_scripts hangs

I’m not sure you can use is_page() in the function.php (citation needed!). Instead of enqueuing the the style sheets, you could echo them in the header.php. So, in the header.php you’d want… <?php if ( is_front_page() ) { echo ‘<link rel=”stylesheet” type=”text/css” href=”‘ . get_template_directory_uri() . ‘/css/homepage.css”>’; } else if ( is_page( ‘corsi’ ) ) … Read more

wp_localize_script not create variable in head section

Your code looks correct. alert(wp_ajax.nonce); should display the nonce. You can also verify the existence of the wp_ajax object via console.log(wp_ajax) in your browser’s Javascript console. wp_localize_script adds the object(s) to the footer (a call to wp_footer() should be present in the theme’s footer.php file). It’ll look like so: <script type=”text/javascript”> /* <![CDATA[ */ var … Read more

enqueue script if page is not equal to

add_action( ‘wp_enqueue_scripts’, ‘ron_scripts’ ); function ron_scripts(){ if(is_home()){ wp_register_script( ‘homescript’, ‘/wp-content/themes/template/js/menu-home-open.js’ ); wp_enqueue_script( ‘homescript’ ); } else { wp_register_script( ‘nothomescript’, ‘/wp-content/themes/template/js/FILENAMEHERE.js’ ); wp_enqueue_script( ‘nothomescript’ ); } } alternatively replace is_home(); with any other method or code that determines what page you are on. ex: might work if(site_url() == get_permalink()){ //do home stuff } else { //do … Read more

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)