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

0
votes
2answers
43 views

How can I get a list of all enqueued scripts and styles?

I'm creating a plugin and I want to get the list of all scripts and CSS used by other plugins. This is my function: function crunchify_print_scripts_styles() { $result = []; $result['...
0
votes
1answer
16 views

jQuery plugin not loading

I am trying to use the below function to enquue 2 scripts (one internal, one external). The internal one ('custom_script') is working, but the 2nd one ('formValidation') isn't (I get a 'validate() is ...
-4
votes
1answer
20 views

Using Headroom.js with Bootstrap4 in Wordpress

So I'm trying to work on a site on my localhost here and I cant figure out why this won't work in Wordpress. I'm not sure if it's the way the scripts being declared or what as I've got a perfect ...
1
vote
1answer
24 views

Script Localization doesn't work

I don't get how script localization works in wordpress. I created an associative array in php: $translations = array( 'value1' =>'This is first value', 'value2' =>'This is second ...
-2
votes
2answers
127 views

comment-reply.js is not loading

I'm building my own website within WordPress from scratch. It's not really a new theme, just everything from the beginning, starting with an index file, header, footer, single, comments, functions etc....
0
votes
0answers
10 views

Comment Reply not loading

The nested comments feature is enable in my settings and I have the following block of code inside my functions.php function my_scripts() { wp_enqueue_script( 'main', get_template_directory_uri()...
0
votes
1answer
18 views

Enqueue scripts in footer

I'm trying to build a plugin and enqueue my scripts to footer. For performance reasons I'd like to load this plugin scripts after the functions.php scripts, because furthermore it will break the page ...
0
votes
0answers
32 views

How to include a plugin's (MailPoet) javascripts using child theme's functions.php

I have to include some javasripts files in all pages of my website. They are required by MailPoet to handle newsletter subscriptions. Now, I may add them directly into the head section, but I'd like ...
0
votes
1answer
23 views

WordPress wp_enqueue_script only adds text to top of page source

All I'm trying to do is add some javascript to a WordPress theme I'm making. My functions.php file looks like this: function my_scripts() { wp_enqueue_script( 'jquery' ); wp_register_script(...
15
votes
4answers
28k 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
38 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
119 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
34 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
523 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
33 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
55 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
40 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
122 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
63 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
38 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
56 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
48 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
21 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
20k 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 ...
1
vote
4answers
7k 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
372 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
26 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
53 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
57 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
56 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
100 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
21 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
72 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
29 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
30 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
365 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 ...
15
votes
2answers
9k 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
31 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
58 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
88 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
35 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
56 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/...