Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [wp-enqueue-script]

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, or provide this function with all the parameters necessary to link a script. This is the recommended method of linking JavaScript to a WordPress generated page.

0
votes
0answers
10 views

WordPress Menu Item Script Dropdown Login

I have a client I'm redoing a website for on WordPress and I'm trying to implement a login system that when they click on the menu item at the top of their website, it has a login that drops out and ...
0
votes
1answer
14 views

Unable to declare AOS library in functions

Greeting WP Devs, I am planning to transfer the script libraries in my function.php . In my function.php I registered AOS function mypage() { if ( is_page( 'mypage' ) ) { wp_register_script( '...
2
votes
2answers
41 views

Load CSS/Javascript in frontend conditionally if block is used

Assuming I have no infinite scroll or anything else going on in my theme: Is there a way to enqueue my custom Gutenberg block styles and scripts so they are only (lazy) loaded in the front-end when ...
0
votes
1answer
26 views

enqueue admin styling and scripts only on plugin page

I'm still learning so please bear with me if I sound a little confusing. Having lots of fun BTW while I learn. I'm creating a plugin with admin specific JS and CSS but I don't want those scripts and ...
0
votes
0answers
12 views

plugins_url not returning correct directory

This plugin works on my live wordpress instance. However, on my local machine, none of the javascript is getting triggered. I think it has to do with plugins_url and it most likely not returning the ...
0
votes
2answers
24 views

enqueue_script with filemtime javascript not working

Hey guys so I'm trying to enqueue a javascript with filemtime but every time I do it the custom js script I wrote doesn't seem to enqueue. function add_js_scripts(){ wp_register_script('lib', ...
0
votes
0answers
63 views

Preload key requests using wp_enqueue

I'm currently doing some speed optimisation and one of the main things scoring the site down is:- "Preload key requests 2.64 s Consider using to prioritize fetching resources that are currently ...
0
votes
0answers
22 views

Jquery enqueued script in child theme not proccing

I created a child theme of the theme twenty-seventeen. I want to add some scripts, especially Jquery libraries and some custom Jquery to animate the homepage. This is what I have in functions.php (...
0
votes
0answers
147 views

Uncaught ReferenceError: jQuery is not defined

It is a well discussed problem, but I can't find the issue (I've been researching it for days now); Uncaught ReferenceError: jQuery is not defined jQuery seems not te be loaded within my custom ...
0
votes
1answer
31 views

Why my wp_enqueue_script doesnt work on some page?

My wp_enqueue_script from my theme is working on home page and not on other page. This is my web : https://welgo.id. And here is not working : https://welgo.id/listing/rs-bandung-eye-center-bandung/ ...
0
votes
1answer
17 views

When to use wp_register_script() function?

When I came to know the function wp_register_script(), I had some questions came to my mind: Should I register each script first and then enqueue it? And is this a best practice? Or, Should I ...
0
votes
0answers
16 views

Set a parent script presence status true so that child scripts load in wordpress

I didn't know how to write a good title for my problem. I'm trying to integrate some scripts in js file and dequeue them to decrease browser requests. So let's say we have some child scripts which ...
1
vote
3answers
28 views

Enqueuing javascript files

I'm trying to enqueue a JS file (located at /js/example-script.js), just to get an alert on page load. Can anyone tell me what I'm doing wrong? In my example-script.js: jQuery(document).ready(...
0
votes
2answers
24 views

Enqueue script for development purposes only?

I'm trying to create a new development workflow and for that I need to enqueue some scripts to be available only when I'm developing. What is the correct way to do this? Should I use WP_DEBUG as a ...
0
votes
2answers
109 views

Enqueuing script is adding extra text for google maps [closed]

I'm setting up a google map on my site and I'm trying to set the enqueue my scripts up but am getting an error: I have placed this code in my functions.php (actual api key not used here): function ...
4
votes
1answer
313 views

Get the list of enqueued/registered scripts for a specific post?

I am exploring how to build a theme where most of the pages are loaded using the Rest API. I can load the index page and from there make GET requests to get posts json data and after build its content ...
0
votes
1answer
24 views

how to load css and js based on post template

I have created a post having the following template: <?php /* Template Name: Html Code Template Post Type: post, page */ ?> <?php get_header(); ?> <?php get_sidebar(); ?> <div id=...
0
votes
3answers
64 views

Adding Gravity Form With if(is_page) Is Not Working

Please bear with me as I am a front-end developer trying to grapple with PHP. I am attempting to add a gravity form to specific pages on my website website by adding a function to my functions.php ...
0
votes
1answer
29 views

Not all my scripts are enqueueing

From both scripts, only 'custom.js' is loaded, not common.js this is in my functions.php file: <?php function custom_scripts () { if (!is_admin()) { wp_deregister_script('jquery'); ...
4
votes
1answer
182 views

How do I enqueue a script to run inside the Gutenberg editor?

I'm using the Gutenberg editor as a replacement for a whiteboard in a classroom. I'm able to make the classroom more interactive by having students work directly inside the Gutenberg editor. As a long-...
0
votes
0answers
27 views

Enqueue CSS and Script only if needeed

How can I enqueue a CSS code only on the pages which use that CSS? Usually it's quite easy to know if a particular CSS or JS is used on a WordPress Post: it's enough to check if the shortcode is used ...
1
vote
1answer
60 views

Select2 in WordPress

I have seen some best practices in WordPress about enqueueing scripts in WordPress. The scripts that are already in WordPress core should not be added again, but call that from WordPress core. I want ...
0
votes
0answers
17 views

How to add google tagmanager to default registration page?

How I add google tag manager to default registration page? So Ill can track the registration flow? Ill need to add a google the tagmanager script to the head and a tagmanager noscript to the body of ...
0
votes
0answers
26 views

How do I keep children of certain parent menus expanded by default on a sidebar?

We are using advanced sidebar pages menu: https://wordpress.org/plugins/advanced-sidebar-menu/ to expand / collapse children menus on a sidebar. By default, the parent sidebar menu is expanded, ...
1
vote
0answers
25 views

Styles and scripts inside template part

Is there anything wrong with including style and script tags inside a template part? The template part which I'm using like something more similar to a vue/react component is working correctly but ...
0
votes
1answer
18 views

Adding styles/scripts to specific page

I'm trying to add styles and scripts to specific template, But it's not working. In functions.php I tried: if( is_page_template('file.php') ){} if( is_page_template( get_template_directory() . 'file....
0
votes
1answer
34 views

How to use wp_register_script / wp_enqueue_script for multiple queries

I have a wp_register_script / wp_enqueue_script and need to reuse this for multiple states, how do I do this? This is the code: wp_register_script( 'scount', get_template_directory_uri() . '/...
-1
votes
2answers
162 views

Enqueue Script with data attributes

I am looking to enqueue this script on the header of a wordpress page <script src="https://js.chargebee.com/v2/chargebee.js" data-cb-site="mydomainame" ></script> I know how to use ...
5
votes
2answers
363 views

Removing specific style from wp_head

I'm not a WordPress developer, I'm trying to help a friend who has a WordPress website. Here is the problem: In the template, wp_head() function adds bunch of styles and scripts. I want to remove ...
2
votes
1answer
26 views

Can't get JS code to work with shortcode

I am trying to create a plugin and I've got stuck. I am trying to register and enqueue a script from a shortcode: This is my shortcode: add_shortcode( 'gear-guide', 'gg_product_front_end' ); This ...
2
votes
3answers
76 views

wp_enqueue_script being ignored in custom theme

I am trying to enqueue a js file (calculator.js) from my theme's functions.php file. I have a desktop theme and a smartphone theme, and I am using a plugin to switch between the two themes depending ...
1
vote
3answers
44 views

Load JS Script only for custom post types

I am using this code and I am not sure why the script is not loaded. I believe the syntax is correct since I am trying to load the script only on the "events" custom post type single posts. ...
1
vote
1answer
38 views

Why won't my scripts load?

I am having trouble loading scripts in functions.php I've done this before so I'm sure I'm overlooking something but as far as I can tell it is correct and I have tried copying and pasting from other ...
1
vote
1answer
265 views

wp enqueue script- jQuery not loading

i have added this code to add jQuery wp_enqueue_script( 'jqueryadd','http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js', array(),'22.23',true ); But i think that this is unnecessary ...
0
votes
2answers
30 views

Trying to enqueue script - Nothing Happens

I am trying to enqueuer a script after registering it but I am getting an error. This is the script: function _test() { console.log("Test"); } That's the PHP: function fsg_shortURL() { ...
0
votes
1answer
29 views

Proper way of minifiying java script files in wordpress theme

How can make sure that java script minification in wordpress does not create issues once it is done in theme development point of view? Does wp-enqueque script order matter in minification process? ...
1
vote
0answers
211 views

How to enqueue or include json file to a plugin

I have a file called settings.html that includes two files in the footer which are a javascript file and a json file. <script src="script.js"></script> <script src="settings.json">&...
0
votes
0answers
58 views

Enqueuing multiple stylesheets with a child theme

I've successfully enqueued a parent stylesheet and child stylesheet. I'd like to enqueue a third - ultimately a style.php file, but a second-style.css would be a good start. It's not working for me ...
0
votes
0answers
68 views

WP Enqueue Script Error

Hi I am struggling to figure out why most of scripts are not working, mostly the owl carousel. The error I could not figure out is Uncaught TypeError: $ is not a function at scripts.js:1 I tried ...
1
vote
1answer
147 views

How to add Bootstrap Tour JavaScript to WordPress Admin Panel Dashboard Widget

I am developing a theme and want to know how to add Bootstrap Tour Script to a Custom Dashboard Widget. Basically I want to include the Bootstrap Tour Script to the Admin Panel so I can write a ...
0
votes
0answers
96 views

How to move medielement scripts to footer?

This seems like a new thing since 4.9 https://make.wordpress.org/core/2017/10/30/mediaelement-upgrades-in-wordpress-4-9/ In previous versions medielement and dependencies were all loading in footer ...
0
votes
1answer
20 views

How to import the css in the plugin admin area?

I am trying to insert it using the following code. The css file style.css is just inside the plugin's directory. add_action('wp_enqueue_scripts', 'callback_for_setting_up_scripts'); function ...
1
vote
1answer
1k views

how to use wp_localize_script in custom page template

I have the template called homepage that assigned to home page and bottom of a template I have script tag. now I want to use my json in that script tag. home-template.php add_action('...
0
votes
0answers
227 views

Using Anime.js on a WordPress site

I'm trying to get anime.js to work on a WP site but getting nowhere. I'm loading it in functions.php (wp_enqueue_script, add_action) together with a script file I'm calling it from. I can see the ...
0
votes
2answers
2k views

How to en-queue bootstrap 4 to theme?

i tried enqueue the bootstap with functions php wp_enqueue_style('bootstrap4', 'https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css'); wp_enqueue_script( 'boot1','https://code....
0
votes
1answer
27 views

wp_enqueue_scripts are apearing inline rather than as links

I'm not sure whats going on with my code here, I'm enqueuing scripts like so: wp_enqueue_script( 'lightbox', '/wp-content/themes/'.get_stylesheet() . '/js/lightbox.js'); However when I view the ...
0
votes
2answers
255 views

How can I load an inline script after the enqueued scripts in admin?

I am having a heck of a time finding an answer to this solution. I have googled everything I can think of but I can't find anything. I want to load an inline JavaScript tag in the footer of the admin. ...
0
votes
0answers
15 views

Adding links to .js and .css files on specific custom pages

Is there a plugin or setting in WP that will allow me to include JS/CSS file links (both internal and external) on custom pages? Currently I have skin options for Custom CSS, JS Code before </head&...
0
votes
2answers
70 views

Problem in functions.php file

I'm trying to include all my css and JS files of a theme using functions.php. Following is what I have done so far: <?php function blogroom() { wp_enqueue_style('bootstrap', ...
0
votes
1answer
155 views

enqueing Javascript and CSS

Whenever I check my website on gtmetric, google Insights, Pingdom etc... I always get feed back of render blocking JS Currently I enqueue all my scripts as so: <head> <link rel="...