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
0 answers
11 views

How to enqueue/register JS and CSS files to elementor addon [closed]

Hope you are doing well. I designed a elementor widget (slider) using slick carousel. when I am inserting the widget in elementor page, it is working fine when opening the page in browser ([screen ...
user avatar
0 votes
1 answer
16 views

Enqueue Script in WordPress

How to enqueue script in WordPress ? When I am using below code script enqueue properly. wp_enqueue_script( 'adc-handlebars', get_template_directory_uri() . '/vendors/handlebars/handlebars.min.js', ...
user avatar
  • 377
0 votes
0 answers
16 views

Get localize of a loaded javascript

I am writing a cache code to combine JS files I add JS files in a single file and then dequeue the script using wp_dequeue_script But the problem is wp_dequeue_script will dequeue extra inline data (...
user avatar
0 votes
0 answers
34 views

Adding google fonts to WordPress theme

I am trying to add google fonts to a custom WordPress theme. Therefore I tried to enqueue selected three font faces at once to make it fast loading. So, I use the below codes to register and enqueue ...
user avatar
0 votes
0 answers
22 views

Dynamically add Js

I have a basic bunch of CSS/Js files defined in my functions.php file. There I register and enqueue those scripts and stylesheets. But in specific situations I want to load additional scripts based on ...
user avatar
0 votes
0 answers
22 views

JS / jQuery in Elementor pages vs JS file

I have a lot of JavaScript and jQuery functions that are all working fine, but it's quite fragmented and hard to maintain as some are in Elementor HTML widgets, others in specific Pho functions annd ...
user avatar
0 votes
0 answers
50 views

How to enqueue a script which is type module without using script_loader_tag filter?

I'm creating a theme and i want to upload it to envato. I have a javascript file that is type module and i can enqueue it and then use script_loader_tag filter to add type module to it by these lines. ...
user avatar
  • 1
0 votes
0 answers
20 views

Load JavaScript on specific page with @wordpress compiler

I'm new to WordPress development. I have been following a tutorial in Udemy to build my new WordPress website. As recommended by the trainer, it is useful to use npm to package the JavaScripts using &...
user avatar
  • 1
1 vote
0 answers
15 views

Change script type and src of plugins in theme

So I have to implement OneTrust which requires all <script type="text/javascript"> to be converted to <script type="text/plain"> and there are various plugins that use ...
user avatar
  • 21
0 votes
1 answer
47 views

Bootstrap and jQuery error: $ is not defined

I'm trying to use the Bootstrap collapse component and just can't get it to work. I believe the HTML is proper, but whenever I click on the element that should trigger the collapse, I get an Uncaught ...
user avatar
  • 13
0 votes
0 answers
22 views

How to use wp_enqueue_script properly?

I'm trying to load mine scripts, but it doesn't work properly. function theme_enqueue_assets() { wp_enqueue_script('load_more', get_stylesheet_directory_uri() . '/assets/js/load_more.js', array('...
user avatar
0 votes
1 answer
26 views

Ajax on the Administration Side of plugin - wp_localize_script - how to pass value from JQuery to PHP function in class?

I have built a plugin and I need to use ajax in the admin and have followed the documentation here: https://codex.wordpress.org/AJAX_in_Plugins However, this is out of date and I cannot find any ...
user avatar
  • 31
1 vote
0 answers
62 views

Is there a way to check for an attribute of a script when using script_loader_tag?

The block of code adds the attribute async to a array of Javascript files. Is there a way to check if the files have already have the attribute assigned and if yes, to skip it? function async_scripts( ...
user avatar
  • 151
0 votes
0 answers
34 views

Get webpack to work on child theme

I have previously created a child theme for the purpose of customizing some pages and it works fine, but now I'm facing some issues overriding the app.js file from my main theme. I'm following the ...
user avatar
  • 111
0 votes
0 answers
11 views

Code for front end validation for forms not working

I cannot get my front end validation messages to work in my form. I don't know where I am going wrong in the code. Can somebody please advise me. First Name Last Name Email ...
user avatar
0 votes
0 answers
27 views

Wordpress load same script two times

I write a basic plugin with custom css/js. I use wp_enqueue_script for my custom script and use hook 'init' to register script in front-end page. But wordpress load this javascript file two times with ...
user avatar
1 vote
1 answer
32 views

Enqueue scripts not working with if is page conditional tag in functions.php

Is this even the correct way of including scripts on a specific page? function insert_mapsvg_scripts() { wp_enqueue_style( 'mapsvg_css', site_url('/mapsvg/css/mapsvg.css') ); wp_enqueue_style( '...
user avatar
  • 111
0 votes
1 answer
23 views

How to load Javascript code or functions.php later in a child theme?

I'm placing some JS code in functions.php in my child theme but it loads first than anything else. Thus, I'm trying to get it to load later than the rest cos it needs Jquery. I tried enqueuing WP's ...
user avatar
0 votes
1 answer
23 views

Run JS function when JQ enqueued

I would like to run a javascript function when jQuery is ready. This doesn't work: wp_enqueue_script('jquery'); ?> <script> (function() { doJQstuff() })(); </script> ...
user avatar
  • 21
0 votes
0 answers
35 views

Filter enqueued styles and scripts

I am looking for a way to reorganize the scripts/styles queue in WP. I am well aware of the fact altering the queue may have undesired effects, but in this case there are solid reasons for doing it ...
user avatar
0 votes
1 answer
43 views

"Intercept" enqueing of 3rd party's JS file

I'm using a 3rd-party plugin, but I need to load the non-minified version of a specific JS file of the plugin, to avoid some image preloading caching; in the AJAX call when preloading some images, the ...
user avatar
  • 121
0 votes
1 answer
128 views

Can't seem to get javascript code working from child theme

my javascript code isn't working. I put the js folder next to the other folders, the astra-child folder, astra folder and other themes. Is this correct. Then in the js folder, I created custom_script....
user avatar
0 votes
0 answers
32 views

Moving Javascript from footer to header

Plugin class is using action-hook for wp_footer in it's init function to assing script to footer. In that callable it does do two things: Registers the script (with in_footer argument true) Enqueues ...
user avatar
0 votes
1 answer
42 views

Correct way to enqueue page specific CSS file

I am looking for an alternate way than using functions.php and applying conditionals based on each page's ID, instead I would like to enqueue the CSS right at the top of each page like this: <?php ...
user avatar
0 votes
1 answer
18 views

Why won't wp_enqueue_script work within any plugin file?

I have a plugin, from which within one of the files I am trying to include a JS file the proper way: function inveroak_feed_search_enqueue() { wp_enqueue_script('inveroak-feed-search', ...
user avatar
  • 297
1 vote
0 answers
77 views

How can I manually enqueue plugin scripts

I am trying to manually use the accordion tool from wpbakery. Now before my question gets closed, my question is not about wpbakery. My question is how to load the correct scripts so that the ...
user avatar
  • 5,322
0 votes
1 answer
33 views

jQuery will not work on page from snippet or file

I've been banging my head against the wall on this, My jQuery code runs perfect in CodePen, the WP site in console also runs it perfect, however I simply can not get it to run on the actual ...
user avatar
  • 111
0 votes
1 answer
83 views

Add type to enqueued script inside plugin

So I don't know if this is possible, but I have a question - We are integrating OneTrust and one of the requirements was to change <script type='text/javascript'> to <script type='text/plain&...
user avatar
  • 15
0 votes
0 answers
25 views

Advanced method to control cache of enqueued style/script

I have a WordPress website with medium-level traffic, ~10,000 unique visitors a day. Arround 30% of my daily visitors are recurrent. I constantly make some UI improvements: colors, font-size, ...
user avatar
0 votes
1 answer
246 views

Dequeue / Deregister script and replace it with a new plugin

I think I've read a dozen posts about dequeuing and deregistering scripts, but I haven't been able to make it work properly in my situation. My situation: The "uListing" plugins are part of ...
user avatar
0 votes
0 answers
28 views

Fire action after enqueue script

I have a color switcher but its css files load before default css files.so, it doesn't work good.I want to fire it after enqueue script.after all css and js files on the website, I want to load my ...
user avatar
2 votes
3 answers
688 views

Enqueue script o style only if a template part is loaded

I have registered some styles and scripts that should be loaded if a template part is loaded in a template file. For ex: in home.php <?php get_template_part( 'template-parts/external_links'); ?> ...
user avatar
0 votes
1 answer
29 views

Do I just put the html in a page when enqueueng or do I also have to reference js file from the html page [closed]

I am trying to get my javascript to work in my page, but I have always just put the html on the actual page, but now am wondering if I am supposed to put the <script src before the html as well to ...
user avatar
0 votes
0 answers
22 views

wordpress plugin add page when activate

I have written a WordPress plugin and want to make new page when plugin activate I tried by the following its loading only html its not including css style-sheet which is included in html file if ( ! ...
user avatar
0 votes
0 answers
66 views

Can't replace Gutenberg editor's pre-publish conditions with my own

I'm trying to adapt Welcher's answer here to replace Gutenberg's default pre-publish conditions with my own - namely for requiring that a category and a featured image are set. However, no matter what ...
user avatar
0 votes
0 answers
143 views

JQuery UI button not working in the Wordpress 5.8 theme

I have enqueued the necessary scripts via wp_register_script and wp_enqueue_script in Wordpress (v 5.8): <script type='text/javascript' src='https://<mywebsite.com>/wp-includes/js/jquery/...
user avatar
  • 213
1 vote
1 answer
107 views

Is my approach to enqueue styles inefficient?

I'm kinda new to wordpress and programming in general. I have the following question. Recently I came across this article and wanted to use this approach in the wordpress theme I'm working on. I wrote ...
user avatar
1 vote
0 answers
70 views

How to enqueue JavaScript file that depends on CSS stylesheet

I'm trying to set up a build process for JS/CSS assets to work with my WordPress theme. In my JavaScript file, I can do this: // src/button.js import React from 'react'; import './Button.css'; ...
user avatar
  • 133
1 vote
1 answer
98 views

How to target block variations with has_block()?

We often use has_block to enqueue scripts only if a certain block is present. With something like vimeo you used to be able to write has_block('core-embed/vimeo'). What is the proper way now to ...
user avatar
0 votes
1 answer
39 views

How to load a css file depending on the current role

I have created a custom role (b2b) and I am trying to load a css file while the 'b2b' role is logged in or the administrator. I have tried the code below and I can't get it to work. Any help or ...
user avatar
  • 1
0 votes
1 answer
24 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 ...
user avatar
0 votes
2 answers
162 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('...
user avatar
0 votes
1 answer
72 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 = ...
user avatar
  • 209
0 votes
0 answers
30 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 ...
user avatar
0 votes
1 answer
60 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 ...
user avatar
0 votes
1 answer
3k 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....
user avatar
0 votes
1 answer
369 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, ...
user avatar
  • 362
0 votes
1 answer
158 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, ...
user avatar
0 votes
1 answer
114 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() { ...
user avatar
1 vote
1 answer
616 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 ...
user avatar
  • 1,617

1
2 3 4 5
21