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
18 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 ...
0
votes
1answer
14 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 ...
0
votes
1answer
52 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....
0
votes
0answers
18 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 ...
0
votes
1answer
28 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 ...
0
votes
1answer
17 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', ...
0
votes
0answers
27 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 ...
0
votes
1answer
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 ...
0
votes
1answer
22 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&...
0
votes
0answers
24 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, ...
0
votes
1answer
107 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 ...
0
votes
0answers
26 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 ...
2
votes
3answers
322 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'); ?> ...
0
votes
1answer
25 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 ...
0
votes
0answers
21 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 ( ! ...
0
votes
0answers
39 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 ...
0
votes
0answers
130 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/...
1
vote
1answer
103 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 ...
1
vote
0answers
40 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'; ...
1
vote
1answer
39 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 ...
0
votes
1answer
22 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 ...
0
votes
1answer
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 ...
0
votes
2answers
83 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('...
0
votes
1answer
38 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
19 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
27 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
2k 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
186 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, ...
0
votes
1answer
70 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
86 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
312 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
45 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
1k 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
33 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
52 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
43 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
116 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
191 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
25 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
31 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
118 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
28 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
136 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
29 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
26 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
208 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
66 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
1answer
33 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
25 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
1answer
108 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 ...

1
2 3 4 5
21