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

Ajax navigation and scripts loaded only on certain pages

If the plugins are nice about it and register all of their scripts upfront, and then just enqueue them as needed, you should be able to enqueue all of them to load all the time. Find out the handles they were registered with and enqueue them. add_action(‘wp_enqueue_script’, function() { wp_enqueue_script(‘example-handle’); wp_enqueue_script(‘another-example-handle’); }, 20); However, some … Read more

Auto create description in post

You need to use save_post_post hook and use $wpdb->update() method. The code – add_action( ‘my_save_post_post’, ‘save_post_post’ ); function my_save_post_($post_ID, $post ) { global $wpdb; $post_content=”You are viewing “. $post->post_title .’! These are great hairstyle designs in our ‘. get_the_category_list( ‘, ‘, ”, $post_ID ) .’ section. Hope you try this look and feel on your … Read more

Make different sites on multisite reference same script

Hi this is what I did to solve it: add_filter( ‘script_loader_src’, ‘change_src’ ); add_filter( ‘style_loader_src’, ‘change_src’ ); function change_src( $url ) { if( is_admin() ) return $url; // Don’t filter admin area return str_replace( site_url(), ‘www.mysite.com/mydefaultnetworksite’, $url ); } I’m using both those filters because I want it to apply to script and stylesheet urls. … Read more

How to deregister scripts all at once

Its already answered on this link <?php //To remove all script from the page function remove_all_scripts() { global $wp_scripts; $wp_scripts->queue = array(); } // to remove all stylesheet add_action(‘wp_print_scripts’, ‘remove_all_scripts’, 100); function remove_all_styles() { global $wp_styles; $wp_styles->queue = array(); } add_action(‘wp_print_styles’, ‘remove_all_styles’, 100); ?> It will remove all the scripts enqueued by standard method. Manual … Read more

Plugin’s required JS not being inserted in my theme

Hey by using enqueue script to add all js and css file wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); Example here /** * Proper way to enqueue scripts and styles */ function theme_name_scripts() { wp_enqueue_style( ‘style-name’, get_stylesheet_uri() ); wp_enqueue_script( ‘script-name’, get_template_directory_uri() . ‘/js/example.js’, array(), ‘1.0.0’, true ); } add_action( ‘wp_enqueue_scripts’, ‘theme_name_scripts’ ) i am sure … Read more