Adding Pinterest Script Before Closing Body Tag

Yes, you have to use wp_enqueue_script function. Pass $in_footer argument as true and your script will be added before closing body: function my_scripts_method() { wp_enqueue_script( ‘pinterest’, ‘//assets.pinterest.com/js/pinit.js’, array(), false, true); } add_action( ‘wp_enqueue_scripts’, ‘my_scripts_method’ );

include jquery plugin file not working

Your uses of wp_register_script and add_action are incorrect. Try the following code: function you_fancy_js(){ wp_register_script( ‘custom-script’, plugins_url( ‘/js/jquery.js’, __FILE__ ), array( ‘jquery’, ‘jquery-ui-core’, ‘jquery-validate’ ) ); wp_enqueue_script( ‘custom-script’ ); } add_action(‘wp_enqueue_scripts’,’you_fancy_js’); This assumes that your custom jQuery functions are in jquery.js and jquery, jquery-ui-core, and jquery-validate are already enqueued. You do not need admin_head. The … Read more

How to use wp_enqueue_script, style when required

You can create a shortcode: function load_scripts() { wp_enqueue_script(‘moder’); wp_enqueue_style(‘styles’); } add_shortcode(‘load_scripts’, ‘load_scripts’); Then use the shortcode to enqueue the scripts/styles: [load_scripts] Or so: do_shortcode(‘[load_scripts]’); In terms of running when required, you have to make sure that if you’re loading something that requires these, that you either execute the shortcode or enqueue those scripts/styles, since … Read more

“admin_enqueue_scripts” hook or $_GET[‘page’]?

The advantage of using the value provided by WordPress in the hook variable is future compatibility with WordPress Versions and not having to worry about $_GET variable manipulation by way of the user or another WordPress plugin. Checking the $_GET array works, but can be unreliable especially when other poorly coded plugins start messing with … Read more

Ordering stylesheet above using functions.php

You should not be outputting anything on the wp_enqueue_scripts hook, just enqueueing. Move your css output to a function hooked to wp_head with a lower priority than 8, which is when the enqueued styles are printed in wp_head: function folio_enqueue_css() { wp_enqueue_style( ‘theme’, get_template_directory_uri() . ‘/assets/css/style.css’, false, ‘1.0’, ‘all’ ); } add_action( ‘wp_enqueue_scripts’, ‘folio_enqueue_css’, 1 … Read more