Links a script file to the generated page at the right time according to the script dependencies, if the script has not been already included and if all the dependencies have been registered. You could either link a script with a handle previously registered using the wp_register_script() function, ...

learn more… | top users | synonyms

14
votes
4answers
27k views

How to add a javascript snippet to the footer that requires jQuery

I know I can add a script file to the footer of wordpress that requires jquery using this code: <?php function my_scripts_method() { // register your script location, dependencies and version ...
7
votes
2answers
4k views

How do I implement the WordPress Iris picker into my plugin on the front-end?

This question here is asking the same question as I am, but there were no adequate answers nor a selected correct answer so I am asking again hoping if I ask in a more coherent manner I might get a ...
-1
votes
2answers
33 views

javascript not loading in wordpress

I originally posted this in the stackoverflow, but I believe it is better posted here as I am using wordpress and a wordpress function. I am trying to add the jquery cycle plugin (http://jquery....
0
votes
1answer
111 views

Wordpress and Raty.js

Thanks in advance for any help you can provide. I am trying to implement raty.js into a archive template for a custom post type I have created. As far as I understand I only need to enqueue the ...
0
votes
1answer
29 views

Proper use of wp_localize_script?

I want to pass an array of data to my script mygaloochart_script located in the chart.js file. Here's what I tried: //I'm no using $atts directly because of reasons $dataToBePassed = array ( ...
-1
votes
1answer
506 views

Theme now uses require.js and enqueue script no longer works

I created a small custom script that fixes a sidebar at different point depending on if there is a banner. I used enqueue script in my child functions file and then a custom.js file with my ...
0
votes
2answers
31 views

My stylesheets are not enqueuing

I'm in Wordpress 4.5.2 on Windows 10 and I'm trying to register and enqueue my stylesheet in Wordpress, but it just isn't working. I'm having the same problem with jQuery. I have this code in a ...
4
votes
3answers
2k views

Using wp_enqueue_script on shortcode function handler

I have this code function this_is_my_shortcode(){ wp_register_script('per-pas-belanja-online', plugins_url('js/per-pas-belanja-online.js', __FILE__), array('jquery'), '1.0.0'); ...
0
votes
0answers
35 views

wp_enqueue_script and wp_enqueue_style doesn't load content over https

I have a problem with serving scripts and styles over https. Scripts included via functions.php and used proper get_stylesheet_directory_uri(), here's some code: add_action( 'wp_enqueue_scripts', '...
0
votes
1answer
39 views

wp_enqueue wont work on some files?

So if i use the following in functions.php in the root off my child folder it works as supposed: add_action( 'wp_enqueue_scripts', 'register_my_scripts'); add_action( 'wp_enqueue_scripts', '...
-1
votes
3answers
88 views

Enqueue scripts based on browser width?

Is it possible to load scripts through wp_enqueue_script based on a browser's width? Thanks
0
votes
1answer
57 views

Wordpress Jquery+scripts enqueue issue

I'm having some issues in loading a custom jquery slider into a wordpress site I'm working on: I'm not super proficient with theme development but I'm studying hard and I spent lots of days trying ...
0
votes
1answer
32 views

Getting a variable inside foreach from PHP to JS after localization

I believe I have properly enqueue'ed and localized my script - I've got $q showing up in the DOM. Now I'm sure I'm missing the simple last step to accessing a variable in the JS function. Here's my ...
0
votes
0answers
9 views

Add a “NEW” banner to bottom of every new post [duplicate]

I'm working on http://juniorgoldreport.com The owner wanted a "new" banner tag on new post's, so to make it easy I was going to put it on the images, but because of scaling and different images it's ...
8
votes
2answers
12k views

Load a script just to custom post type in admin

I have created a custom post type "portfolio" with something like this : $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => ...
0
votes
2answers
39 views

enqueue script on custom post type archive page

How do I enqueue a script on the header if the user is on an archive page of a custom post type? The custom post type is called limitedrun and the page is called archive-limitedrun.php. I tried this ...
1
vote
1answer
34 views

How to To Filter wp_enqueue_script() Scripts on Some Pages

I am using following code to add some scripts in WP pages like function add_js() { wp_deregister_script('jquery'); wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "")...
1
vote
2answers
1k views

How to add JavaScript file using wp_enqueue_scripts?

I have made a very simple JavaScript script. There is 1 .js file with a lot of code, and in the HTML file there is only 2 lines. The script works fine when I test it on a plain HTML page, but when I ...
0
votes
2answers
19 views

link to JS library using wp_enqueue_scripts not working

I've added the following code to functions.php of my activated child theme: function fullpagejs() { $slimscroll = get_stylesheet_directory_uri() . '/library/fullPage.js-master/vendors/jquery....
19
votes
6answers
19k views

wp enqueue inline script due to dependancies

Is there a way to use wp_enqueue_script() for inline scripts? I'm doing this because my inline script depends on another script and i would like the flexibility of inserting it after it's loaded. ...
2
votes
0answers
15 views

Script won't execute in the media manager

I'm trying to execute a jquery script on the click of a button in a custom tab of the media manager, but it does not seem to work. I have been told this might be due to the button not being loaded ...
-5
votes
1answer
55 views

Exclude script from running on certain pages [duplicate]

I would like to exclude a script from running on certain pages, Please can you tell me the best way to do this? Example: I do not want the script to run on page-id-9, page-id-11, but I want the ...
1
vote
4answers
6k views

Enqueue core jQuery in the footer?

I have this in my functions.php file and I can't get jQuery to load in the footer. The includes file loads in the footer fine, though. What else do I need to do? function starter_scripts() { ...
4
votes
2answers
357 views

Get php var inside javascript file (making plugin)

I was making a plugin and I have a javascript file where I want to take some options saved in the database to show well the function. So I have this: function wp_home(){ wp_enqueue_script( '...
0
votes
2answers
23 views

Custom script file enqueue has “?ver=4.5.1” when loading and doesn't update

I'm loading a custom script file using an enqueue and here's the output: <script type='text/javascript' src='.../wp-content/themes/enfold-child/js/custom_script.js?ver=4.5.1'></script> ...
0
votes
2answers
47 views

Overwrite wp_enqueue_script under certain condition

I have an enqueued script called custom_js that loads the file js/custom.js. I want the file to change when a certain condition is true, but it does not seem to work. Here is my code: add_action('...
0
votes
1answer
27 views

Enque Typekit Fonts - Not Found

I'm trying to enqueue a typekit on my WP site in a function using code below: /** * TypeKit Fonts * * @since Theme 1.0 */ function theme_typekit() { wp_enqueue_script( 'theme_typekit', '//use....
1
vote
1answer
39 views

wp_enqueue_media() Will not load JS on the theme

I've added wp_enqueue_media() to a specific page (before including the header) on my custom theme but it flat out will not any of the JS on the page. I've already done the basic troubleshooting: ...
0
votes
1answer
55 views

is_page_template & is_page in functions.php not working

I use the following script to call the maps JavaScript in the page-about.php template. But its actually not working. The scripts are executed nowhere: // Load maps scripts function maps_scripts() { ...
0
votes
1answer
16 views

add_action wp_enqueue_script priority level only works for admins

I have a function in my functions.php file that loads all of the scripts into the header for my website. The line to run the function was like this: add_action('wp_enqueue_scripts', '...
0
votes
0answers
60 views

jQuery is not defined in wordpress

Got the not defined error for the script below : JQuery.noConflict(); jQuery(document).ready(function($) { /** Code using $ referencing to jQuery **/ }); Can't explain why and solve the problem,...
1
vote
1answer
26 views

Calling JavaScript file with Custom Plug In

So, the goal is to use jQuery Validation for a custom form. Maybe I'm going about this the hard way. But, here's what I'm doing: Uploaded the jQuery Validation file to my theme folder Created plug-...
0
votes
0answers
28 views

wp_enqueue_scripts doesn't work for template pages

In my child theme's functions.php I wrote : function add_js() { echo "path is : ".get_stylesheet_directory_uri().'/js/script.js'; wp_enqueue_script( 'script', get_stylesheet_directory_uri().'/...
0
votes
1answer
350 views

Check for Twitter Bootstrap Loaded

I am developing a plugin that uses Twitter Bootstrap Modals, but would like to prevent loading bootstrap if it's already loaded. <a href="https://github.com/MaxCDN/bootstrap-cdn/issues/111#...
1
vote
1answer
1k views

Only let plugin add actions to wp_head & wp_footer on single posts

I'm using a a plugin (Comments Evolved) on a recently built site. The issue I'm having is that this plugin globally enqueueing and adding actions to the head and footer of all pages. I'd like to ...
14
votes
2answers
8k views

What does wp-embed.min.js do in WordPress 4.4?

Question What does the wp-embed.min.js file do? I noticed it is added to the end of my blog page footer. How can I get rid of it? Effort After some googling and I found Embeds on the Codex. Why ...
0
votes
1answer
22 views

I can't enqueue Suggest.js in frontend - not added

my suggest.js is not being added in front-end. All scripts are correctly loaded but this one. I want to load it only on frontpage so: add_action('wp_enqueue_scripts', 'homescripts'); function ...
0
votes
1answer
33 views

If is multiple page templates

Via functions.php, I'm trying to enqueue specific scripts and styles based on two separate page templates. Here's what I've tried: if ( !is_page_template('page-templates/page-index.php') && !...
12
votes
3answers
1k 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
71 views

linking stylesheets and scripts with functions.php

I am following along with this tutorial. I am trying to link the javascript and css files that are usually linked in the header using wp_enqueue_scripts in functions.php. With what I have now, only a ...
0
votes
1answer
33 views

javascript file is not enqueing

I'm working on a custom wordpress theme. The js file is in wp-content/theme/custom-theme/js/bootstrap.min.js. I'm not able to load this on page while I can load the custom CSS file. My code is: ...
0
votes
1answer
50 views

How to dequeue / deregister parent theme style

I'm making a child theme, and I'd like to remove the Google font style that it calls for in 'fonts-style' function nada_theme_styles() { wp_register_style( 'fonts-style', '//fonts.googleapis.com/...
4
votes
3answers
736 views

Remove extra Google Maps script

I'm developing a plugin that use a Google Maps API. The plugin enqueuing script in this way: wp_enqueue_script('google-maps', 'http://maps.google.com/maps/api/js?sensor=false&callback=initialize&...
0
votes
2answers
127 views

Enqueue Javascript After ALL Other Scripts (Including Async Scripts)

I have a script I'd like to include with Wordpress. This script relies on another (prettyPhoto) to run, as well as on JQuery being loaded. I'd like my script to be the very last script to be included ...
20
votes
2answers
16k views

How do I dequeue a parent theme's CSS file?

My parent theme (Starkers) adds a CSS file that I'm trying to remove (I want to use @import instead so I can override styles more easily). Starkers has the following in its functions.php: add_action( ...
1
vote
1answer
71 views

wp_enqueue_scripts not working inside shortcode

<?php class OrdersShortcode { function __construct() { add_shortcode('order_ajax_form', array(&$this, 'order_ajax_form')); } function my_enqueued_assets() { ...
3
votes
1answer
306 views

Is it possible to enqueue the Youtube API script or does it have to be inline?

The code below is the main part of a function in my functions.php which returns a div and script which ultimately output a youtube API iframe to the template where the code had been called from. At ...
0
votes
1answer
34 views

get_stylesheet_directory() in child theme breaks parent scripts

I tried hard finding another question that may answer my query but failed, so if you point any duplicates that would help. Here is my situation I have a parent theme and I am developing a child ...
0
votes
1answer
85 views

Different body image backgrounds on different pages, posts and categories

I am trying to implement the ability to choose a different body background image to different posts, pages and categories. I am using Advanced Custom Fields to add an image field to every post, page ...
0
votes
2answers
43 views

Where to enqueue stylesheets for plugin?

I want to enqueue stylesheet to plugin I'm developing, like this: function utm_user_scripts() { $plugin_url = plugin_dir_url( __FILE__ ); wp_enqueue_style( 'style', $plugin_url . "/css/style....