The wp-enqueue-script tag has no wiki summary.
2
votes
2answers
177 views
How to move style from template file to <head> section?
Imagine the following situation:
//header.php contains:
<header id="header">logo and navigation</header>
//my-template.php contains:
<?php get_header(); ?>
<style ...
0
votes
1answer
179 views
wp_enqueue_script before wp_head
If this works (and it's the way people do in a bunch of themes around the web):
<html>
<head>
<!-- stuff -->
<?php wp_enqueue_script('jquery'); ?>
<?php ...
0
votes
1answer
55 views
admin_print_styles incuding $_SERVER['DOCUMENT_ROOT']
All the Javascript isn't working in the admin area on my production server.
Locally it works fine. I have narrowed it down to /wp-admin/wp-header.php line 72-78
do_action('admin_print_styles');
...
0
votes
2answers
953 views
WP_enqueue_script() loads them always in wp_footer()?
This is my example code placed in functions.php:
function my_init_method() {
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-core', false, array('jquery'), false, false);
...
0
votes
2answers
88 views
scripts not enqueueing
I have been beating my head against this for a couple of hours now and can't seem to figure it out. I am trying to enqueue a script into my page with the following code in my functions.php.
function ...
1
vote
1answer
89 views
issues with wp_enqueue_script in my plugin
So I am working on a plugin and am trying to trigger a js file whenever a post is saved. I have been reading up on this all morning and cannot seem to find why this is not working. Any advice? If I ...
0
votes
1answer
308 views
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 ...
0
votes
0answers
53 views
wp_enqueue_scripts Script dependency Catch 22? [closed]
I have a function in my functions.php that calls my custom tracking JavaScript file. It relies on Piwik's JavaScript to be loaded beforehand or else I get this error:
Uncaught ReferenceError: ...
4
votes
1answer
166 views
Which method is best to enqueue scripts
I'm currently authoring the development of a plugin for wordpress, and I'm having trouble figuring out which would be the best way to add scripts to the plugin. I'm in the process of adding more ...
2
votes
1answer
67 views
Hyphens vs. periods in the script slug in wp_register_script?
I have seen script and style handles written in two different ways in wp_register_script and wp_enqueue_script (the same applies to wp_register_style and wp_enqueue_style):
wp_register_script( ...
1
vote
3answers
612 views
How do I force wp_enqueue_scripts to load at the END of <head>?
I am loading scripts via wp_enqueue_scripts in my child theme.
The only problem is that my style.css script get loaded BEFORE plugin scripts, yet I need to override the css in the plugins with my ...
0
votes
1answer
114 views
wp_enqueue_scripts called twice?
I had some problem with WP recognizing a is_single condition for loading scripts called in function.php.
I put a error_log(is_single()) to check what was going on.
When opening a post page the log ...
0
votes
2answers
391 views
include jquery plugin file not working
My code for include js as follows:
function you_fancy_js(){
wp_register_script( 'custom-script', plugins_url( '/js/jquery.js', __FILE__ ), array( 'jquery', 'jquery-ui-1.8.18.custom.min', ...
1
vote
2answers
126 views
Script won't load via plugin class
I'm not sure why this script is not loading or producing any load errors via Firebug. Here is my plugin script:
class AV_Slideshow{
function __construct(){
$this->hooks();
}
function ...
0
votes
1answer
299 views
wp_enqueue_scripts in a plugin's class
I'm trying to enqueue jQuery UI in a plugin under a class method. I have this so far:
class AV_Slider {
function slider_load_js(){
wp_register_script('jquery-ui-core', ...
0
votes
1answer
166 views
Enqueueing Scripts/Styles mid-page
Since WP 3.3, the codex has been updated for both wp_enqueue_script and wp_enqueue_style that you can now enqueue both mid-page (within the HTML body).
I see this as an advantage because:
It's ...
1
vote
1answer
543 views
force enqueue script to be first in order of prominence
I have a few scripts which are being enqueued,
the problem is that I want to force the order of prominece to which these scripts are loaded. There is one in particular which is loaded from a plugin ...
1
vote
2answers
82 views
Enqueue scripts to a specific header-<name>.php?
I've multiple header files (header-name.php), they are mainly being used by different custom post types.
Is there any way to enqueue script to only a specific header?
At this moment I'm targeting it ...
0
votes
1answer
183 views
Adding Pinterest Script Before Closing Body Tag
According to the Pinterest website in order to add the Pinterest button to any page I have to add the following just below the closing body tag:
<script type="text/javascript" ...
1
vote
2answers
184 views
Enqueued scripts and styles loading in WordPress Dashboard as well
For a moment, I wondered if my test site got hacked -- my WordPress site's dashboard was all broken (cosmetically). But when i looked at the source code of the page, I noticed that the "scripts and ...
5
votes
1answer
1k views
Register and enqueue conditional (browser-specific) javascript files?
The WP.SE community has always advised the use of wp_register_script and wp_enqueue_script for adding scripts in a theme/template (and likewise, wp_register_style and wp_enqueue_style for ...
3
votes
1answer
689 views
Is This The Most Efficient Way To Add Javascript Files?
I am currently rewriting an HTML template into a Wordpress theme. It has a lot of code dependencies, and I'm wondering if this is the proper, most efficient way to add it. This code is listed in my ...
1
vote
1answer
332 views
How do I get the $handle for all enqueued scripts?
Is there some way to get the $handle for each script that has been enqueued?
Is there some array that holds all the handles so that I can loop through it and do something using each $handle?
0
votes
2answers
100 views
How to execute a simple php script in WP (I don't think wp_enque_script applies here)
I have a wordpress page where I want to include a budget calculation tool here: http://tinyurl.com/c2fwy9f
This budget calculation tool is of course tied to a php script that executes the fields in ...
1
vote
1answer
206 views
Check if page/post has any anchors that link to an image jpg/gif/png
What I'm aiming to do is add fancybox to a site I'm developing, but I only want to enqueue the JS/CSS etc if the page/post needs it.
My thoughts are that I would need to check all the anchor tags on ...
2
votes
1answer
521 views
Problem using is_single() to enqueue script from functions.php
I'm having trouble only adding scripts to single post pages. I need to both include and exclude certain scripts using is_single() but it doesn't work either way I try it.
I have the template tag on ...
0
votes
1answer
55 views
Wordpress Plugin Authoring question about jquery and css
When I'm writing a plugin, do I assume that jquery is included, or should I always wp_enqueue_script it and let wordpress figure it out?
Also, what's the best practice for getting an image path ...
1
vote
2answers
312 views
Enqueue script from widget method (of extended WP_widget object) possible? (slightly different from other variations of this question)
I am creating a widget plugin that a user could potentially use multiple iterations of the widget multiple times on a single widget-area / multiple widget-areas on a single page. Because of its ...
1
vote
1answer
149 views
Enqueue script with url_query variables?
Is there an easy way to enqueue a JavaScript file with url_query values populated?
I have a php file underneath my js directory with JavaScript headers that I want to generate some dynamic JavaScript ...
0
votes
1answer
145 views
wp_enqueue_script does not recognize my js file?
my wp_enqueue_script does not seem to work, i can't understand why :
i have a child theme of twenty ten,
i wrote this in my functions.php file (in my theme) :
<?php
function my_scripts_method() ...
0
votes
1answer
137 views
Plugins loading multiple copies of JQuery
I'm having issues where multiple copies of jQuery are being loaded onto the page via plugins that require jQuery.
I Just want to confirm that if I have 3 plugins active on my page, that all properly ...
0
votes
1answer
117 views
Page not found when trying to link to files in child theme directory
I'm trying to create a child theme based on Toolbox 1.4 by Automattic.
I have my scripts file saved as child_theme/js/scripts.js on my server and I enqueue it by using
wp_enqueue_script( 'scripts', ...
2
votes
1answer
811 views
require.js to load javascript
whilst wp_enqueue_script seems to work it's not really elegant. I'm currently making a WP front end which uses MVC (backbone.js) and has literally 30+ seperate Model/View/Collection/Controller scripts ...
0
votes
1answer
121 views
Loading Images from Javascript on the Front End
I'm getting some 404 errors on image paths in this plugin I'm building.
I'm trying to build a plugin that has some Javascript and images (like a close icon and a progress bar) that I want to load on ...
3
votes
2answers
3k views
Notice that the wp_enqueue_style is not being called correctly!
I get this error due to one of the plugins which I rely on.
Notice: wp_enqueue_style was called incorrectly. Scripts and styles
should not be registered or enqueued until the wp_enqueue_scripts,
...
3
votes
2answers
174 views
What are the benefits of using wp_enqueue_script?
Is there any real benefit to using wp_enqueue_script on small self-managed sites? For instance, Modernizr, why enqueue it through a function rather than call it directly inside the document head?
I ...
0
votes
1answer
1k views
How do I make script load after jquery?
function load_my_script(){
wp_register_script( 'my_script', get_template_directory_uri() . '/js/myscript.js', 'jquery' );
wp_enqueue_script( 'my_script', 'jquery');
}
add_action('wp_enqueue_scripts', ...
1
vote
1answer
135 views
getting a js file for one page
wp_register_script('SliderViewer', '/js/SliderViewer-1.2.js');
wp_enqueue_script('SliderViewer');
get_header();
however, mydomain.com/js/SliderViewer-1.2.js doesn't exist.
My js is in the ftp at
...
3
votes
3answers
512 views
How to enqueue script if widget is displayed on page?
I created a widget that uses a jquery plugin, and I used is_active_widget to enqueue the script, it's working fine but it's also including the script even on pages that doesn't show this widget.
so is ...
0
votes
2answers
287 views
Is there a way to set the order of wp_footer hooked functions?
I was wondering if we can set the order of a function hooked to wp_footer(), I created a function that echos:
<script> ajsfunction(); </script>
and I also enqueued the js file of this ...
1
vote
2answers
86 views
Making a plugin only available on the front-end for the logged in super admin
I made a little plugin that enqueues 1 .js file and 1 .css file into a theme's front-end. All it does it load a grid on top of the theme so I can visualise the design.
If this plugin was activated ...
0
votes
1answer
231 views
admin_enqueue_scripts not rending JS file correctly
I'll keep this short and sweet, I want to load a JS file in the admin panel as part of my plugin, and through tons of research I have a few different options that have all ended with the same problem ...
8
votes
2answers
299 views
Conditionally enqueue a widget's script/stylesheet in HEAD (only when present on page!)
I've been trying to load scripts and styles for a WordPress widget with the following conditions...
The scripts MUST load in the HEAD (else they break).
The scripts must ONLY load when the widget ...
0
votes
1answer
146 views
Need help with adding jQuery script to WP and calling script to page
I've written a pretty simple jQuery script, and I don't know how to call it. It's in its own directory.
First, how do I register it, and then how do I enqueue it?
I assume that's the order it's done ...
1
vote
3answers
529 views
How can I remove the site URL from enqueued scripts and styles?
I'm dealing with an SSL issue and I would like to strip the domain from all scripts and styles being output via wp_enqueue_scripts. This would result in all scripts and styles being displayed with a ...
0
votes
2answers
808 views
Best Way to Include Scripts on a Specific Template Page
This is something that has always confused me and I could use some help.
I want to do four things directly above the closing body tag:
include jQuery (WordPress version is fine)
include a jQuery ...
0
votes
2answers
109 views
JavaScript enque stopped working
Somewhere along the line I have messed up my js enqueue I am not sure how. I have the following in my functions.php file and I am including <?php wp_footer(); ?> in my footer.php before the js ...
5
votes
5answers
3k views
Including jQuery and jQuery files the correct way
I´m having some trouble with this. I´m not sure how to do it the correct way, and I read so many different techniques and ways to do it that I dont know what to make of it.
Some questions and ...
2
votes
1answer
949 views
wp_enqueue script my_javascript_file in the footer
I am trying to place my_javascript_file in the footer. According to the documentation $in_footer is the fifth value and it is a boolean so I have it set to true.
Currently it doesn't show up anywhere, ...
0
votes
1answer
198 views
wp_enqueue_script not loading my custom js file
I am using the following code below in my functions.php, However app.js is not found when I inspect it in the resources tab.
It is looking for it in ...