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.

Filter by
Sorted by
Tagged with
0
votes
0answers
9 views

Enqueue scripts not working with jQuery document ready

I added my several javascript files manually in the header in the early stages of development and everything was working. Then I decided to use the enqueue scripts function in functions.php to enqueue ...
0
votes
0answers
11 views

Enqueued script with jQuery dependency not working

Enqueued Bootstrap with URL src and jQuery as dependency is not working: wp_enqueue_script( 'bootstrapjs', 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.3/js/bootstrap.min.js', array( '...
0
votes
1answer
18 views

wp_dequeue_script for a Plugin

I am trying to remove a line of script in the footer of my page that a plugin is inserting on pages that I am not using the plugin at, homepage for example. I am using the below code for some reason ...
0
votes
0answers
16 views

wp_editor() youtube link does not load video

Hello I am trying to get a preview of the youtube video when pasted to the editor but it keeps loading plain instead of loading the video preview. I have created an options page in admin side for a ...
0
votes
1answer
13 views

wp_add_inline_script not adding when script_loader_tag filtered

I'm trying to add the new GA4 code to an existing site, and there seems to be some conflict / ordering issue between script_loader_tag filters and wp_add_inline_script. My functions.php looks thusly: ....
1
vote
1answer
27 views

Wordpress not showing jQuery

I am trying to link a new JavaScript file where I want to add some custom jQuery to the content. But it is not showing on my website or pages. Here is the code in functions.php and my JavaScript file ...
0
votes
1answer
22 views

wp_is_mobile dequeue not working

According to this topic: Dequeue Scripts and Style for Mobile not working? I used the last answer but for Slider revolution plugin and it does not work: This is my function in functions.php: ...
0
votes
0answers
14 views

JavaScript works for me but not for a co-worker

So, I'm having some trouble with my code. Everytime I refresh the website the code is working for me, but my co-worker has some slight visual bugs (parts of the site is not loading in, animations don'...
0
votes
0answers
7 views

How many times should a block's edit be being called?

It feels like the answer should be once, or maybe once per instance of the block on a post/page. I'm writing a new block, and for debugging purposes, I'm logging the post_id very early in my block's ...
0
votes
1answer
34 views

Is “document loaded” different on admin side than public side?

I'm writing a plugin to support Google Graphs. It's working fine on the public side, but is intermittently rendering weirdly on the admin side, and also intermittently throwing errors that make me ...
1
vote
1answer
20 views

Adding tawk.to code just before body tag on functions.php file

I would like to add tawk.to widget script just before the body tag. I would like to add the code to the functions.php file of my child theme. How can I do this? A code sample will assist a long way. ...
1
vote
1answer
49 views

Enqueue scripts all over but not in single.php

I need to insert this script in the footer on the home, in categories, in pages, in the tags in the search but NOT in single.php: function live_search() { wp_enqueue_script('live_search', ...
0
votes
1answer
34 views

How to make my shortcode load scripts and styles, from within the plugin?

This sounds like a silly problem, but I was searching for an answer, and couldn't find anything. And the things that I did find, I tried and didn't work or were very vague. Content My Problem What I ...
0
votes
1answer
29 views

why wp_enqueue_scripts() not working?

here is code function custom_theme_script(){ wp_register_style('bootstrap', get_template_directory_uri() . '/css/bootstrap.css' ); wp_enqueue_style('bootstrap'); wp_register_style('style'...
0
votes
0answers
23 views

How to do chunked JS files in WordPress?

Webpack outputs chunks of JS files in order to parallelize downloads over HTTP/2 but unfortunately WP's wp_enqueue_script requires that only one file be loaded to represent a script, forcing us to ...
0
votes
0answers
17 views

Is it possible to load recaptcha script only in url with fragment identifier (#)?

I have tried various snippets, like this: <?php add_action( 'wp_print_scripts', 'load_captcha_script', 100 ); function load_captcha_script() { if ( !is_page( '#register' ) ) { ...
1
vote
0answers
14 views

How to inject variables into public-facing JS using wp_enqueue_script

I'm using wp_enqueue_script to enqueue the public-facing JS of my WP plugin: wp_enqueue_script($this->PluginName, plugin_dir_url(__FILE__) . 'js/public.js', array(), $this->version, false); And ...
0
votes
1answer
36 views

How can I force Dynamic CSS via ACF values to update on page load?

I'm trying to dynamically change the background color of a post on scroll to colors set in post options via an ACF color picker. I was able to source enough code examples to get it working (I thought) ...
0
votes
0answers
22 views

How to add image zoom on archive products page?

What I am trying to achieve is to have the gallery zoom enqueued into my products archive page, not just in the single product page. This is how far I have gotten so far. It supposed to work, but it ...
0
votes
1answer
46 views

“The editor has encountered an unexpected error” After add defer tag to java script

I added below script to add defer tag in javascripts. Once it added to function.php Gets error on create post "The editor has encountered an unexpected error." I cannot create or edit post. ...
1
vote
1answer
76 views

How to add extra attributes to the script tag added via wp_localize_script()

So, wp_localize_script() are awesome to add custom data to a script. And these data gets added to the HTML like: <script id='woocommerce_some-js-extra' type="text/javascript"> var ...
0
votes
1answer
171 views

how to enqueue javascript to manipulate acf input field in admin?

I have an acf field 'select' that i want to remove some options from using js but i can not acces the field it returns undefined <select id="acf-block_5f35006ff2da4-field_5f3cce8a89941" ...
0
votes
3answers
262 views

Bootstrap slider not working

I have a html bootstrap slider which works fine with captions and everything.I would like to integrate it into my Wp theme (my forst one, so total newbie).I found a code, which seems to helo, but it ...
1
vote
1answer
53 views

Retrieve URL of Script/Style and Dependencies

Given script X Y and Z how would I get the list in PHP of X Y Z and their dependencies? I need to load several scripts that have dependencies. Normally I would do this via wp_enqueue_script but in ...
0
votes
0answers
15 views

Adding Dynamic Attributes in Script Tag for 3rd party JS

I saw that someone had asked how to add attributes in script tag for 3rd party JS here: Adding Additional Attributes in Script Tag for 3rd party JS My question is how to also make those attributes ...
0
votes
1answer
37 views

Enqueue script globally

This only works for admin dashboard. add_action('admin_enqueue_scripts',array($this, 'login_register96_adminscripts')); And this only works for the user place. add_action( 'wp_enqueue_scripts', array(...
0
votes
0answers
160 views

Get with jQuery the value of an ACF field

I'm trying to store in a variable the content of an ACF field so that later on I can use it in a jQuery function using the plugin "Simple Custom CSS and JS". I found what I thought was the ...
0
votes
1answer
29 views

Changing the CSS with a plugin

I'm trying to make a plugin that changes the CSS file. My client want to change the colors each season, and we want to make it foolproof so they won't break anything. I've managed to create the option ...
0
votes
0answers
16 views

How to identify what page when using wp-load.php

When using WordPress, I can easily identify pages using is_page('100') or is_front_page(), is_home, is_single() etc... But, I have built a custom PHP script and included into WordPress using: define( '...
1
vote
1answer
53 views

Why are files enqueued with wp_enqueue_style and wp_enqueue_script 404 Not Found?

code script Error net::ERR_ABORTED 404 (Not Found) Scrips Not Loaded
0
votes
3answers
41 views

wp enqueue style on about us page

On functions.php I have the following which works on the homepage : function load_page_styles() { if (is_front_page()) { wp_register_style('home', get_template_directory_uri() . '/css/...
0
votes
4answers
126 views

Problem with wp_enqueue_script

I've spent a lot of time trying to solve this problem and am really lost. Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the ...
0
votes
1answer
17 views

wp_enqueue_script error with `ID`, `post_title`, `post_name` of none object

I'm trying to make my first plugin, but when I try wp_enqueue_script the script file, I get errors about the ID, post_title, post_name, even though its a single page (i.e. not posts kind of page). // ...
0
votes
1answer
12 views

Enqueue plugin for specific pages

I want to enqueue my plugin for certain pages. I've tried several things but nothing worked so far: add_action( 'init', 'my_enqueue' ); function my_enqueue() { global $post; if( $post->ID ==...
0
votes
1answer
18 views

Wordpress - enqueue js issue - page broken, no error

I'm trying to migrate a theme to Wordpress. As usual, I imported all CSS, and now I'm moving on to the JS portion. This is how my function.php looks: <?php function greennectar_files() { // ...
0
votes
1answer
269 views

How to enqueue CSS and JS only on specific template?

I'm busy with my home.php template and I need a few CSS/JS files that are only loaded on that specific template. I tried doing it with if ( is_page_template( 'home.php' ) ) { //ENQUEUE CODE }, but ...
0
votes
0answers
29 views

Using bootstrap slider - importing css or js issue

I downloaded a html theme from here: https://colorlib.com/preview/?fbclid=IwAR0bCSqkNMgW4Sogyosq96bSqZFEI0yzjR_UcKXSCAhmPQKey795P7zkRkI#timezone I'm trying to make it work as a WP theme. I added all ...
0
votes
0answers
40 views

How to wrap HTML comments around enqueued styles?

Is it possible to output HTML mark-up around enqueued stylesheets? I enqueue as follows... function enqueue_theme() { wp_enqueue_style('looper-default', get_stylesheet_directory_uri().'/looper/...
0
votes
0answers
20 views

How to load Dashboard default media files via HTTPS even when Browser URL has HTTP

How to load Dashboard default media files via HTTPS even when Browser AddressBar URL has HTTP On all Admin Dashboard pages, I want to force the loading of all CSS, JS via https, even when URL in ...
0
votes
0answers
39 views

I am getting Admin-ajax.php 400 Error

I am implementing some changes to my website's page with AJAX. I have enqueued my js file in functions.php add_action( 'wp_enqueue_scripts', 'add_my_script' ); function add_my_script() { ...
1
vote
0answers
12 views

How to integrate my HTML and javascript into my child theme

I have a javascript script, html, and css I put together on JSfiddle that I now need to essentially put on a page in wordpress. I'm using a child of the generatePress theme. I'm doing it this way ...
0
votes
1answer
31 views

Copy permalink to clipboard automatically when publish/update posts?

When a post gets published/updated, a message will be displayed which gives the permalink. Yes we can copy the permalink to clipboard manually, but I want it to be copied automatically, just like it ...
1
vote
2answers
58 views

Include Custom Style & Script into Custom Post Type Single Template

I'm creating a plugin to add a custom post type. For every custom post type, I also create custom single template. The custom single template is not using get_header(); or wp_head() functions, it is ...
-1
votes
1answer
20 views

WordPress | enqueue_scripts in a child's theme returns error

I intended to load a script within a child's theme because I wanted to experiment with a feature. Initially, I loaded the script as follows: // loading menu toggle function function ...
0
votes
0answers
21 views

Script loads before dependency is loaded wp_enqueue_scripts()

hope you can help me with this issue I am enqueuing the following scripts add_action('admin_enqueue_scripts', function () { wp_enqueue_style('rwp/customizer-custom-controls.css', asset_path('...
0
votes
0answers
52 views

Pass post ID to JavaScript outside the loop

I try to pass the post/pages ID to my JavaScript file. url and template_url works but the id just return 0 on every post. PHP: // Register scripts wp_enqueue_script('scripts', ...
0
votes
0answers
11 views

load graviryforms scripts in dashboard admin menu

I want to use a gravityforms in my admin_menu; what I did is: add_action( 'admin_menu', 'teacher_form_menu' ); function teacher_form_menu() { add_submenu_page( 'hsaja_settings', ...
0
votes
0answers
113 views

Find out the reason that the Styles and scripts in the theme are loading properly in localhost but Not in server after deploying

My custom theme works well on my localhost, but when I upload it to my domain, it can not enqueue any of my styles and javascript. I have everything done correctly. wp_head & wp_footer installed, ...
0
votes
1answer
125 views

Wordpress wp_enqueue_style and wp_enqueue_script not working

I was following a wp theme developement tutorial but somehow my wp_enqueue_style and wp_enqueue_script not working here is my code functions.php <?php //Adding the css and js files function ...
0
votes
0answers
59 views

Test CDN link from function.php or wp_enqueue_script/style?

How can I check if CDN link is alive from function.php file on wp_enqueue section? E.g. I have jQuery CDN and I have downloaded jQuery on local. How can I test before mount theme (WordPress site) is ...

1
2 3 4 5
20