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.

1vote
1answer
44views

Trying to create a shortcode that displays taxonomy terms in a dropdown

I have a snippet that displays all terms from specified taxonomy in a drop down menu. The code works perfectly when it's hardcoded but I am struggling to get it to work as a custom shortcode. The ...
user1048696's user avatar
0votes
1answer
54views

Wordpress generating Undefined Variable warning

Please help! I updated my php to 8.0 and my WordPress install to the current version (6.7.1), and now get the following warning messages on my site: Warning: Undefined variable $post in /home/...
stacy's user avatar
1vote
1answer
54views

Object name undefined using localize script

Iam having problems enqueueing a script with wp_localize_script. I have done this several times before and I cannot see what Iam doing wrong here. I have changed the handle of the script several times ...
LWS-Mo's user avatar
  • 1,591
0votes
0answers
24views

Frontend Enqueued Files in the Backend

I am currently developing a plugin and I need to get the handlers of various enqueued files in the theme. I have tried working with global $wp_scripts and global $wp_styles, but I only get the scripts ...
David's user avatar
0votes
0answers
51views

Uncaught ReferenceError: custom_ajax is not defined

I am trying to create an application that will add products to a cart using PHP and JavaScript + Ajax. In order to do so, I have written this script in functions.php: // Enqueue Fetch API script ...
BrigantiumXIX's user avatar
2votes
0answers
101views

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
0votes
1answer
23views

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
2votes
1answer
312views

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
1vote
1answer
273views

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
2votes
1answer
332views

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
2votes
1answer
1kviews

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
0votes
1answer
61views

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
0votes
0answers
25views

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
0votes
1answer
40views

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
0votes
1answer
577views

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

153050per page
close