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
1answer
19 views

Add default value from selection <select>

working on my first plugin where a user can select an option from a dropdown and this selection gets saved in a code that gets written into the footer. That works, but the problem is, my default ...
0
votes
2answers
29 views

How can I remove the Wordpress-Version (?ver=5.x) from my plugin

I am working on my first plugin that adds a external script to the footer. Wordpress automatically adds the version number at the end, which I'm trying to remove. What I have so far: add_action('...
1
vote
1answer
18 views

localize_script but data changes dependent on product ID

I currently have this code in my functions.php file. $dataToBePassed = array(); add_action( 'wp_enqueue_scripts', function() { $handle = 'three-d-scripts'; $src = ...
0
votes
0answers
8 views

Enqueue Scripts from Parent Single.php for Child Theme to avoid copying entire file

Using a Child Theme setup, the standard method is to copy the entire single.php file from the parent theme and insert it into the Child theme folder, then modify or add custom PHP as needed. This ...
0
votes
1answer
14 views

how to enqueu customiser/customizer scripts?

my script has one line wp.customize.control('control_id').deactivate() the control DOES exist. as an evidence I inject the above code directly into the browser consol and it works (the control ...
0
votes
1answer
55 views

How to fix : Uncaught ArgumentCountError: Too few arguments to function? [closed]

I am getting this error: Fatal error: Uncaught ArgumentCountError: Too few arguments to function _themename\Lib\Classes\Enqueue::css(), 1 passed in C:\xampp\htdocs\wordpress\wp-includes\class-wp-hook....
0
votes
1answer
33 views

Dequeue Gutenburg Block Library CSS ('wp-block-library') in Admin

I am working on removing the default Gutenberg block library stylesheet and replacing it with custom pared-down styles. I do not want the original stylesheet to load on either the front or back end, ...
1
vote
1answer
41 views

wp_enqueue_script was called <strong>incorrectly</strong>. Scripts and styles

I am not a developer, but I have a theme that is giving me the error wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, ...
0
votes
1answer
75 views

Dequeue styles with query doesn't work

In my theme there is the following code (that is printing some inline css on the head of my site) final class Design_Scheme { /** * Design_Scheme constructor. */ private function __construct() { ...
1
vote
1answer
75 views

Can the index.asset.php file be used with the enqueue_block_editor_assets action?

I'm developing a plugin that registers a PluginDocumentSettingPanel in Gutenberg. As this is not a block, I cannot use the register_block_type function to add its assets, so I have to employ the ...
0
votes
2answers
34 views

WordPress wp_dequeue_script remove all other scripts

I want to override function in child theme to remove specific scripts, which is defined inside a class in parent theme. Parent theme functions.php class Theme_Assets extends Theme_Base { /** ...
0
votes
2answers
100 views

403 error When i send ajax request on Wordpress website

i have to create a specifif form ta register data into the database and send a mail without refreshing the page so i create a script.js file : (function ($) { $(document).ready(function () { ...
0
votes
0answers
24 views

Enqueued script fails

function my_scripts_method() { wp_enqueue_script( 'custom-script', get_stylesheet_directory_uri() . "/js/custom_script.js array( 'query' ),'',true ); } add_action( '...
0
votes
0answers
48 views

Unqueue css file from specific page

I'm trying to unqueue style.css file from a specific page. In my functions.php (child theme) if I add: add_action( 'wp_enqueue_scripts', 'apc_child_desregistra_estilos', 11 ); function ...
2
votes
2answers
31 views

enqueue hover function

I am trying to enqueue a hover function in my functios.php of my child theme, so that when hovering over a title, a div with a text will be visible. The code I am using is this: <?php add_action( '...
0
votes
1answer
33 views

Add custom css file after plugin css with Wordpress Child Theme functions.php

I am trying to enque a css file thorugh my child themes functions.php after a specific plugin css file with the handle openpos.bill.bootstrap. Unfortunately the current code does not load anything. ...
0
votes
1answer
47 views

How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)

I’ve created a plugin for my child theme, in which custom functions are stored. Additionally, within the plugin, I'm also enqueueing stylesheets and .js which control the output of two templates, for ...
0
votes
0answers
16 views

Tracking down a JS error only appearing on live site, not staging

I've been digging into this issue as deep as my expertise allows, but – though I finally have a good clue - I'm now out of my element in terms of fixing it. Hope someone can help. My client's site, ...
0
votes
0answers
16 views

wp_register_script() and wp_register_style() 4th parameter (version) not working for logged out users

I'm enqueuing scripts and styles from functions.php in my custom theme. The 4th parameter is the version number. It's working only for logged in users. wp_register_script( 'my-handle', ...
0
votes
1answer
42 views

wp_enqueue_scripts does not work on admin page

I'm trying to create a slider shortcode with Slick Slider and for some reason it does not work in the admin page in the page builder and I'm getting this error: I already enqueue it in my functions....
0
votes
0answers
20 views

Moving some buddypress scripts from head to footer

I have a buddypress installation and the bellow scripts are running in the head of my wordpress site by default wp-content/plugins/buddypress/bp-core/js/confirm.min.js wp-content/plugins/buddypress/bp-...
0
votes
1answer
40 views

Child theme is not rendering parent and own javascripts (but css loaded properly, js not)

I have a child theme and a quite empty function.php. The CSS from the parent is picked up by the child theme, but the whole JS section from the parent theme is not rendered in the DOM at all. (I am ...
0
votes
1answer
22 views

how can i remove js file from my footer in wordpress

i want to remove a specific js file from specific template. i have seen sone solutions and try them but got no result. following i am writing the code which i tried. add_action('wp_enqueue_scripts','...
0
votes
1answer
14 views

Modifying an enqueued script URL

There is a following code in one of the installed plugins: wp_enqueue_script( 'google-recaptcha', add_query_arg( array( 'render' => $service->get_sitekey(), ), ...
0
votes
0answers
122 views

Using Google Analytics in an enqueued JS file

I have a JS file custom-head.js that I have enqueued to run in the header as noted in functions.php here: function enqueue_files() { wp_enqueue_script( 'head_scripts', ...
1
vote
1answer
40 views

WP CLI Get all Enqueued Scripts and Styles

Normally, I would hook into the wp_enqueue_scripts action in order to gather a list of enqueue'd scripts and styles. However, I have a very intensive process I need to run, thus instead of running it ...
1
vote
0answers
27 views

Enqueue script/style if certain widget has certain value

I want to build a widget by which various social media sharing buttons can be added to front end. In the widget form there will be many checkboxes for social media. Since these sharing buttons require ...
0
votes
0answers
17 views

Script Loaded in Wordpress but won't run

I'm a beginner to WordPress and coding/web development as a whole so I'm not 100% where the problem is coming from but I have a general idea. I'm trying to add a sticky sidebar that sticks after the ...
0
votes
0answers
19 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
1answer
28 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
17 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
144 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: ....
0
votes
1answer
30 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 ...
1
vote
1answer
74 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
33 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
9 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
82 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
53 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
38 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
33 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
120 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
19 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
15 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
141 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
35 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
98 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. ...
2
votes
1answer
358 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
499 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
898 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
2 3 4 5
20