Javascript block in Twenty Twelve theme

By default when you use wp_enqueue_script the script is inserted into the <head> section. This is usually set in functions.php. The argument also has a footer option called $in_footer, if you set this to true, the scripts will instead be added to the footer section. In TwentyTwelve there are several calls to wp_enqueue_script with footer … Read more

Create a short code that inserts js

Put the script into an external file, set the selector there and enqueue it from your shortcode: if(! function_exists (‘aisis_toc’) ) { function aisis_toc() { if ( ! is_singular() ) return; wp_enqueue_script( ‘jquery-toc’, plugins_url( ‘js/jquery-toc.js’, __FILE__ ), array ( ‘jquery’ ), NULL, TRUE); return; } }

Infinite scroll page number [duplicate]

Here’s the original answer. To sum it up briefly: Build a custom plugin Register a custom script Localize this script to add the data from $GLOBALS[‘wp_query’] – numberposts, posts_per_page and found_posts in it. Write a custom event handler that triggers when the infinite scroll function runs. Here’s a link to the original script in the … Read more

adding the full image path to a wordpress javascript file

well first of all, don’t directly inject a script tag like that, use wp_enqueue_script to add your javascript file. additional data can then be passed from php to javascript via the wp_localize_script function. function wpa_scripts() { wp_enqueue_script( ‘wpa_script’, get_template_directory_uri() . ‘/js/script.js’, array(‘jquery’), null, true ); $script_data = array( ‘image_path’ => get_template_directory_uri() . ‘/images/’ ); wp_localize_script( … Read more

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