Skip to main content

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.

2 votes
0 answers
19 views

How to Use Webpack with WordPress Script Modules and Enqueue a Custom Class

I am working on a WordPress project using version 6.5, which introduced support for JavaScript modules. I have a parent theme that exports a JavaScript class, and I want to import this class in a ...
Nani samireddy's user avatar
0 votes
1 answer
19 views

How can I access custom data fetched from posts in a javascript script?

I am trying to fetch the lat, long data from custom fields in my posts in order to make a map layer with them (openlayers). I added custom long and lat fields to each post I created a function to ...
Oh-No's user avatar
  • 101
1 vote
1 answer
71 views

Wordpress Gutenberg Custom Block the viewScript does not get loaded on the frontend when my block is inserted

I recently developed a custom Gutenberg block by utilizing the @wordpress/create-block package, which effectively generated a full plugin framework. I simply needed to tweak some existing files to get ...
Daniel V.'s user avatar
  • 131
1 vote
0 answers
40 views

Custom gutenberg block refuses to load viewScript and I don't know why

I've been struggling with this for hours. I used the @wordpress/create-block package to generate a template for me to create my first block. I've managed to create a hero block with an image uploader ...
Daniel van der Velden's user avatar
1 vote
1 answer
100 views

Gutenberg Static blocks: viewScript doesn't import css for frontend?

I am building static block slider (Swiper JS). Used wordpress/create-block https://developer.wordpress.org/block-editor/reference-guides/packages/packages-create-block/. Besides importing the JS & ...
Ion T's user avatar
  • 25
0 votes
0 answers
28 views

Why is my JS not working on initial load?

I'm having weird issues with one of my JS Files that I added via a child theme. I have enqueued it in the functions.php and added some vars with wp_localize_script. wp_enqueue_script('header-astra', ...
Lina Staudt's user avatar
1 vote
1 answer
598 views

Asynchronous enqueue of the Google Maps API

I am loading the Google Maps API on a lot of Wordpress sites and I have always added it with an enqueue. Lately, we have been getting the following warning on the console: "Google Maps JavaScript ...
Sergi's user avatar
  • 11
0 votes
1 answer
55 views

wp_enqueue_script() with unknown path and maybe symlink

I'm developing a plugin that may also be used as a library in themes or plugins. I need to enqueue a custom script, but I cannot know the absolute path to the script, as the final location of the ...
Gerard Reches's user avatar
0 votes
0 answers
22 views

How to enqueue additional scripts and styles after loading another post into the DOM?

If have a post_showcase shortcode that takes in post_ids as parameters. The shortcode generates buttons that when click will load the given post into a modal. However, the shortcodes within the ...
Gus Beringer's user avatar
0 votes
1 answer
27 views

Selective styles and scripts inclusion

I'd like to know if is there any method that allows to include scripts on specific pages/templates depending if those page have a specific get_template_part inside. Example: I have more than one page ...
MKay's user avatar
  • 179
0 votes
1 answer
250 views

correct way to enqueue js and css files for wordpress shortcode?

I have created a php class file. I am enqueuing the required CSS and JS files in the class's constructor. public function __construct() { add_action('wp_enqueue_scripts', array($this, '...
SDeveloperj's user avatar
0 votes
0 answers
55 views

admin_enqueue_scripts not load custom scripts from cdn

I have this code in a plugin class DashboardCustomizer { public function __construct() { add_action( 'admin_enquque_scripts', array( $this, 'load_custom_scripts' ) ); } /* ...
OHICT's user avatar
  • 133
0 votes
0 answers
19 views

difference between code for admin, user facing (css, js)

So I have two pages, user-edit.php in the admin and a page for members to edit their own profiles. There is a group of section on both that has the same coding, the same css id's, the same classes, ...
Jocelyn Hunter's user avatar
0 votes
1 answer
22 views

the second js file enqueued inside wp plugin isn't read

Inside a wordpress plugin : The second enqueued js file isn't read, need I specify something ? Does registering is necessary when several js files are called (enqueued) ? function ...
imagIne's user avatar
  • 83
1 vote
1 answer
287 views

in_footer: gives syntax error

We used to have the following script in functions.php that worked for many years: add_action('wp_enqueue_scripts', function () { wp_enqueue_script('swiper-script', 'https://unpkg.com/swiper@8/swiper-...
th00ht's user avatar
  • 155

15 30 50 per page
1
2 3 4 5
71