Articles of wp enqueue script

How to place script in footer?

I have a script I want to place in my site’s footer. It’s not actually a file, just a single line of code (the script source is located at an external URL). So my question is, should I enqueue the script or just copy and paste it into the footer?

Best spot for wp_register_script() and wp_register_style()

I need to enqueue multiple scripts and styles in my plugin. However, I do not like the idea of calling wp_register_script() and wp_register_style() every time I need to call wp_enqueue_script() and wp_enqueue_style(). I think it is a good idea to register the scripts and styles once, then call them as necessary as needed. So my […]

How do you enqueue a Visual Basic script using wp_enqueue_script?

Internet Explorer will have errors with VB script files en-queued using wp_enqueue_script. This is probably because the output of enqueue script set the script type to ‘language/javascript’. Are there any solutions besides manually including the VB script with the theme?

using conditionals on enqueue styles

I want to run my css code on a specific page in admin area. What is the best approach please? A: function register_style() { if (is_page..something) { wp_enqueue_style(‘style’, PLUGIN_URL . ‘style.css’); } } add_action(‘admin_enqueue_scripts’, ‘register_style’); B: function register_style() { wp_enqueue_style(‘style’, PLUGIN_URL . ‘style.css’); } if (is_page..something) { add_action(‘admin_enqueue_scripts’, ‘register_style’); }

Problem with wp_enqueue_scripts in plugin

I’ve created the following plugin which requires a js library, however attempts to load the plugin with the line add_action( ‘wp_enqueue_scripts’, ‘calc_script’ ); in place fail with the error unexpected T_STRING any help appreciated. <?php /** * Plugin Name: NME Savings Calculator * Description: A widget that displays the potential savings from installing solar panels. […]

if custom posts type exists and there are posts load script

I have registered a custom post type ‘featured_post’. I am looking for a way to test if the blog home page has any ‘featured_post’ posts on it and if it has load a javascript file. The ‘featured_post’ posts will make a slider at the top of the blog home page. I had this working using […]

Prioritizing wp enqueue scripts error

I wanted to load the following two scripts before any other script so I added priority 1 and 2, however I am getting an error. I read it on a tutorial that this is how to prioritize add_action(‘wp_enqueue_scripts’, array(__CLASS__, ‘frontend_enqueues’, 1)); add_action(‘print_head_scripts’, array(__CLASS__, ‘print_js’, 2)); Warning: call_user_func_array() expects parameter 1 to be a valid callback, […]

Including style.css in Child Theme

Twenty Thirteen uses wp_enqueue_style( ‘twentythirteen-style’, get_stylesheet_uri() ); in functions.php. Wheter I use it or not use it in twentythirteen-child/functions.php the style.css from Child Theme is loaded (it is always loaded) and style.css from parent theme can never be loaded. This is an exception to other files added via wp_enqueue_style(), right? It doesn’t behave like all […]

Including Javascript options

For a WordPress Theme I know javascript files (ending in .js) must be included using wp_enqueue_script in functions.php but how do I include additional javascript code? For example, say I need to add this: jQuery(function($){ jQuery.supersized({ slides: [ ‘’, ‘’ ] }); }); Where would I put this? Do I put it within <script> tags […]

getting a js file for one page

wp_register_script(‘SliderViewer’, ‘/js/SliderViewer-1.2.js’); wp_enqueue_script(‘SliderViewer’); get_header(); however, doesn’t exist. My js is in the ftp at thewebsite -> wp-content -> themes -> BLANK-Theme -> js What’s the path of that? Thanks-