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
21 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
9 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
31 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. ...
0
votes
0answers
21 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
50 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
61 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 ...
0
votes
1answer
36 views

Retrieve URL of Script/Style and Dependencies

Given script X Y and Z how would I get the list in PHP of X Y Z and their dependencies? I need to load several scripts that have dependencies. Normally I would do this via wp_enqueue_script but in ...
0
votes
0answers
13 views

Adding Dynamic Attributes in Script Tag for 3rd party JS

I saw that someone had asked how to add attributes in script tag for 3rd party JS here: Adding Additional Attributes in Script Tag for 3rd party JS My question is how to also make those attributes ...
0
votes
1answer
31 views

Enqueue script globally

This only works for admin dashboard. add_action('admin_enqueue_scripts',array($this, 'login_register96_adminscripts')); And this only works for the user place. add_action( 'wp_enqueue_scripts', array(...
0
votes
0answers
51 views

Get with jQuery the value of an ACF field

I'm trying to store in a variable the content of an ACF field so that later on I can use it in a jQuery function using the plugin "Simple Custom CSS and JS". I found what I thought was the ...
0
votes
1answer
28 views

Changing the CSS with a plugin

I'm trying to make a plugin that changes the CSS file. My client want to change the colors each season, and we want to make it foolproof so they won't break anything. I've managed to create the option ...
0
votes
0answers
15 views

How to identify what page when using wp-load.php

When using WordPress, I can easily identify pages using is_page('100') or is_front_page(), is_home, is_single() etc... But, I have built a custom PHP script and included into WordPress using: define( '...
1
vote
1answer
31 views

Why are files enqueued with wp_enqueue_style and wp_enqueue_script 404 Not Found?

code script Error net::ERR_ABORTED 404 (Not Found) Scrips Not Loaded
0
votes
3answers
36 views

wp enqueue style on about us page

On functions.php I have the following which works on the homepage : function load_page_styles() { if (is_front_page()) { wp_register_style('home', get_template_directory_uri() . '/css/...
0
votes
4answers
68 views

Problem with wp_enqueue_script

I've spent a lot of time trying to solve this problem and am really lost. Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the ...
0
votes
1answer
16 views

wp_enqueue_script error with `ID`, `post_title`, `post_name` of none object

I'm trying to make my first plugin, but when I try wp_enqueue_script the script file, I get errors about the ID, post_title, post_name, even though its a single page (i.e. not posts kind of page). // ...
0
votes
1answer
12 views

Enqueue plugin for specific pages

I want to enqueue my plugin for certain pages. I've tried several things but nothing worked so far: add_action( 'init', 'my_enqueue' ); function my_enqueue() { global $post; if( $post->ID ==...
0
votes
1answer
16 views

Wordpress - enqueue js issue - page broken, no error

I'm trying to migrate a theme to Wordpress. As usual, I imported all CSS, and now I'm moving on to the JS portion. This is how my function.php looks: <?php function greennectar_files() { // ...
0
votes
1answer
100 views

How to enqueue CSS and JS only on specific template?

I'm busy with my home.php template and I need a few CSS/JS files that are only loaded on that specific template. I tried doing it with if ( is_page_template( 'home.php' ) ) { //ENQUEUE CODE }, but ...
0
votes
0answers
27 views

Using bootstrap slider - importing css or js issue

I downloaded a html theme from here: https://colorlib.com/preview/?fbclid=IwAR0bCSqkNMgW4Sogyosq96bSqZFEI0yzjR_UcKXSCAhmPQKey795P7zkRkI#timezone I'm trying to make it work as a WP theme. I added all ...
0
votes
0answers
36 views

How to wrap HTML comments around enqueued styles?

Is it possible to output HTML mark-up around enqueued stylesheets? I enqueue as follows... function enqueue_theme() { wp_enqueue_style('looper-default', get_stylesheet_directory_uri().'/looper/...
0
votes
0answers
19 views

How to load Dashboard default media files via HTTPS even when Browser URL has HTTP

How to load Dashboard default media files via HTTPS even when Browser AddressBar URL has HTTP On all Admin Dashboard pages, I want to force the loading of all CSS, JS via https, even when URL in ...
0
votes
0answers
38 views

I am getting Admin-ajax.php 400 Error

I am implementing some changes to my website's page with AJAX. I have enqueued my js file in functions.php add_action( 'wp_enqueue_scripts', 'add_my_script' ); function add_my_script() { ...
1
vote
0answers
12 views

How to integrate my HTML and javascript into my child theme

I have a javascript script, html, and css I put together on JSfiddle that I now need to essentially put on a page in wordpress. I'm using a child of the generatePress theme. I'm doing it this way ...
0
votes
1answer
30 views

Copy permalink to clipboard automatically when publish/update posts?

When a post gets published/updated, a message will be displayed which gives the permalink. Yes we can copy the permalink to clipboard manually, but I want it to be copied automatically, just like it ...
1
vote
2answers
43 views

Include Custom Style & Script into Custom Post Type Single Template

I'm creating a plugin to add a custom post type. For every custom post type, I also create custom single template. The custom single template is not using get_header(); or wp_head() functions, it is ...
-1
votes
1answer
16 views

WordPress | enqueue_scripts in a child's theme returns error

I intended to load a script within a child's theme because I wanted to experiment with a feature. Initially, I loaded the script as follows: // loading menu toggle function function ...
0
votes
0answers
20 views

Script loads before dependency is loaded wp_enqueue_scripts()

hope you can help me with this issue I am enqueuing the following scripts add_action('admin_enqueue_scripts', function () { wp_enqueue_style('rwp/customizer-custom-controls.css', asset_path('...
0
votes
0answers
36 views

Pass post ID to JavaScript outside the loop

I try to pass the post/pages ID to my JavaScript file. url and template_url works but the id just return 0 on every post. PHP: // Register scripts wp_enqueue_script('scripts', ...
0
votes
0answers
11 views

load graviryforms scripts in dashboard admin menu

I want to use a gravityforms in my admin_menu; what I did is: add_action( 'admin_menu', 'teacher_form_menu' ); function teacher_form_menu() { add_submenu_page( 'hsaja_settings', ...
0
votes
0answers
60 views

Find out the reason that the Styles and scripts in the theme are loading properly in localhost but Not in server after deploying

My custom theme works well on my localhost, but when I upload it to my domain, it can not enqueue any of my styles and javascript. I have everything done correctly. wp_head & wp_footer installed, ...
0
votes
1answer
88 views

Wordpress wp_enqueue_style and wp_enqueue_script not working

I was following a wp theme developement tutorial but somehow my wp_enqueue_style and wp_enqueue_script not working here is my code functions.php <?php //Adding the css and js files function ...
0
votes
0answers
33 views

Test CDN link from function.php or wp_enqueue_script/style?

How can I check if CDN link is alive from function.php file on wp_enqueue section? E.g. I have jQuery CDN and I have downloaded jQuery on local. How can I test before mount theme (WordPress site) is ...
1
vote
0answers
15 views

How to only enqueue script if it's a post

I'm building a plugin and I would like to only enqueue a script that resides in my API if it's a post. Example: <?php /** * The public-facing functionality of the plugin. * * Defines the ...
0
votes
0answers
56 views

Enqueue assets from multiple directories using add_action/do_action

I might not be using the actions correctly, but I think they work for my idea? Maybe? I'm trying to enqueue js and css from various directories based on do_actions. To simplify my setup and to make ...
1
vote
2answers
35 views

Is It Possible to add JS AFTER the Enqueue within the same Function?

i'm adding a function in my child theme's functions.php file that will only work on a specific page. i can successfully Enqueue a 3rd-party jquery script. and i can successfully add my own bit of ...
1
vote
0answers
47 views

How to force that styles are enqueued in the header?

I have a plugin processing a shortcode, that needs specific styles. For this I used wp_enqueue_style. As I just need to enqueue the CSS upon certain parameters of the shortcode, I call ...
0
votes
2answers
22 views

plugin css is not being applied to the page

I looked at this question: plugin css is not being applied to the page? but I couldnt solve my problem. I use below code like the question: <?php function libload() ...
0
votes
1answer
23 views

How to pass data to javascript in custom widget class

I have a custom widget where the user can insert an username in an <input> field. It's working fine, but I need to get the inserted value from php and pass it to the javascript file that is ...
0
votes
0answers
14 views

How to enqueue react assets after build?

I created a react bundle with create-react-app in a custom plugin how do I add the builded assets to the frontend?
0
votes
1answer
30 views

How to use wordpress function wp_enqueue_script() in php?

I have a php function as shown below. The following function is being used at many places. function render_brightcove_player($active_feed, $poster_image = false) { $poster = ''; if ($...
0
votes
2answers
382 views

Ajax is not defined

Stack Exchange long time listener, first time caller. I have found examples on the developer.wordpress site but I have been still struggling. Localizing scripts: wp_localize_script() In my theme's ...
0
votes
1answer
63 views

load-{$page hook} and returned parameter

I am using this code to enqueue scripts and styles to wordpress plugin. This works well, but I am wondering is there some parameter available in my_admin_enqueue_scripts function? Because I would like ...
0
votes
0answers
19 views

enqueue script not working in my site

Here is my code: wp_enqueue_script('wow', get_template_directory_uri() . '/assets/js/wow.js', array ( 'jquery' ), 1.1, true);
0
votes
3answers
699 views

Add extra parameter in <script> tag using script_loader_tag

I am using this code in my plugin to enqueue script: wp_enqueue_script( 'wpfrank-ptbw-pinit-js', PTBW_PLUGIN_URL . 'assets/js/pinit.js', array('jquery'), '', true ); The wp_enqueue_script function ...
0
votes
1answer
125 views

Is there a way to ensure plugin script loads before another script?

I have created a plugin, and it loads some scripts in footer. I want to make sure my plugin scripts are loading before any other scripts. Is there a way to acheive this. I have been behind this for ...
0
votes
0answers
18 views

How to change order inside foreach using wp_enqueue_script?

I have a created a for each loop to load all the script files from my build folder dynamically in the footer with for development and production mode. This way I don't need to manually replace the ...
0
votes
1answer
37 views

Bootstrap Integtration

I wonder how can I integrate only bootstrap 4 grid system instead of : <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-...
0
votes
0answers
57 views

Action hooked on wp_enqueue_scripts running twice

I disabled all plugins on my wordpress and keept only my very simple theme active. On functions.php I let running the following code: add_action( 'wp_enqueue_scripts', function() { // Omitted ...
0
votes
1answer
23 views

Stylesheets and scripts not loading

function spartans_styles(){ wp_enqueue_style( 'maincss', get_stylesheet_uri()); wp_enqueue_style('mybootstrap', get_template_directory_uri() . '/assets/css/mybootstrap.css'); ...

1
2 3 4 5
20