Questions tagged [javascript]

A client side scripting language useful for making interactive web sites. Questions about using JavaScript outside a WordPress context are off-topic but might be asked on Stack Overflow.

Filter by
Sorted by
Tagged with
0 votes
1 answer
8 views

Facing Problem While Running WordPress Hook For Archive, Categories, Author, Date Pages Only

I wrote below code but facing issue to run it only on archive, categories, author, date pages to improve page speed. add_action( 'wp_footer', function () { ?> <script> if( is_archive || ...
  • 3
0 votes
1 answer
29 views

How do i get an Inline style in Gutenberg Block show up in front end?

I am trying to extend a gutenberg block. I have a color picker for my tab content background. At the moment, i can pick and change the background color on the backend, and it saves (refresh pa and ...
  • 3
0 votes
0 answers
11 views

How do I fix this "Uncaught ReferenceError: woodmartThemeModule is not defined"?

The issues in console: at headerBuilder.min.js?ver=7.1.4:1:14 at headerBuilder.min.js?ver=7.1.4:1:2394 (anonymous) @ headerBuilder.min.js?ver=7.1.4:1 (anonymous) @ ...
0 votes
0 answers
16 views

I have custom html mixed with inline javascript that I want added to my WordPress site, how do I achieve this?

I have the following HTML/JS code: <div style="position:relative; transition: all 0.3s cubic-bezier(0.65,0.05,0.36,1); height: 0px;"> <iframe width="100%" ...
  • 1
0 votes
0 answers
15 views

CCF7 Field numbuer prefilled after Click event

Good morning, I created a script to capture dynamic data on my page and pre-fill the form CF7 function reply_click(element) { document.getElementById('offerta_prezzo').value = element.getAttribute('...
  • 1
0 votes
0 answers
13 views

How to update the input[type=number] quantity field using custom buttons?

I have written this code which works perfectly fine in CodePen, to update the value of an input[type='number'] field on my single product listing page. The reason for doing so is to have completely ...
0 votes
0 answers
39 views

Escaping admin_url output being passed to js (esc_js vs esc_url)

I am now hardening my first WP plugin. One of my buttons calls a js function which is making a POST against admin-ajax.php. The non-hardened code contains the following: onclick = 'kuba_postMyStuff(&...
  • 1
0 votes
0 answers
10 views

iOS and ajaxComplete

EDIT: Hmm, it seems to be working now. Maybe some kind of caching issue. Can anyone offer any help? The following code works fine, except on iOS; $( document ).ajaxComplete(function() { $("#...
0 votes
0 answers
16 views

Multi color post title by using custom javascript inside the gutenberg editor?

I'm just getting started with the gutenberg editor. I want the editing person to be able to select parts of the post title wich then opens a toolbar above the selected textpart letting you choose a ...
  • 11
0 votes
0 answers
9 views

hiddenQuestions.find is not a function

I have a code like this: var hiddenQuestions = listQuestions.hidden_questions; var find = hiddenQuestions.find(function (questionId) { return parseInt(question.id) === parseInt(...
  • 31
0 votes
2 answers
62 views

Get Comment Text via REST API

Added Note that this process is in a WP plugin, using thw WP API, so I believe this is appropriate for this SO and should not be closed. The following REST call is used to get a specific comment: var ...
0 votes
1 answer
16 views

Modal pop-up HTML code works on other sites or HTML viewers but not in the custom HTML block within a wordpress page?

I'm not the best at coding, but I've managed to create this html code of a modal pop-up which includes CSS, Javascript, and html... it works in an html viewer or anywhere else except the wordpress ...
0 votes
0 answers
13 views

When trying to run build script with gutenberg (with SVG import) - Error: Plugin name should be specified

I have a theme that is live and has some 10-20 custom gutenberg blocks, Those blocks sometime have svg imported to them like so import logo from './logo.svg' Today when I was trying to work and ...
  • 1
0 votes
0 answers
26 views

Gutenberg core/file add style support in js/ json

I try add style support for file block in gutenberg. my code work for UL/li list: wp.blocks.registerBlockStyle('core/list', { name: 'blue-circle', label: 'Blue Circle', }); I try add: wp....
0 votes
0 answers
17 views

uploading image to wordpress site with javascript fetch function failed

I tried to turn an html div element into an png image than I want upload this image in my wordpress site . I wrote following codes, But it is showing image upload failed. Can You find where is wrong. ...
0 votes
0 answers
15 views

Sending GravityForms to custom HTML

I am in need of some way to get a standard WordPress page/form to send some data to a custom page that has been created from raw html/JavaScript. The custom page works great within WordPress right now ...
0 votes
0 answers
32 views

Weird Javascript:void(0) code in my website

Hello i am bit newbiew of coding but very well expirienced with WP. I am having this website (www.kefaloniataxiservice.gr) there is this kind in my website (INSPECT CODE) that according to Lightspeed ...
1 vote
1 answer
14 views

Limit total tags in the_content

I am using the_content to display content in a custom theme, but I am running into an issue. Right now, I have some JS code that removes the <br> tags and replaces them with </p><p> ...
  • 1,133
0 votes
0 answers
13 views

How can I look at/edit what's being sent to post.php when I hit the publish/update button?

I want to change the content of what's being sent to post.php when I click on the publish/update button. Specifically I want to append content using javascript. So let's say I'm clicking on update, I ...
  • 103
0 votes
0 answers
20 views

Reinitiate Gutenburg's blocks using javascript

I'm developing a WordPress plugin that manipulates some Gutenberg blocks using javascript. For better understanding, create a table in a post and run the code below in the console: let tableHtml = ...
0 votes
1 answer
35 views

Is it possible to add javascript to template parts

Is it possible to add javascript to a template part, specifically I would like to add alpine.js to a template part. Any time I add a x-data="menuOpen" or even a data attribute I get This ...
  • 3
3 votes
1 answer
33 views

Execute javscript when theme customizer loads (autosave issue)

I have a theme that is having an issue when there are unsaved theme changes, then the user restores an autosave. My theme has some jquery that watches for a font to be changed, then updates a second ...
  • 33
0 votes
1 answer
79 views

How to add a new attribute to core wp block editor without npm?

I need to add a new attribute with color selector to a core paragraph/heading block. What would be braces-color="#5a6a81" for example. I've been googling all day and only found examples with ...
  • 3
0 votes
0 answers
19 views

WP Customizer get control value on change

I've written a function for my WP theme based off of this question:Changing the entire control choices using wp.customize with JavaScript My code is as follows: ( function( wp, $ ) { wp.customize....
  • 33
0 votes
0 answers
20 views

Slick slider not working on wordpress

I added all slick files and enequed them in my fuctions.php- console is clean there are no error messages for that now. I initialized slick in my custom js file and called the class slider from my ...
  • 3
0 votes
0 answers
10 views

How to Update a variable even if the web page reloads in js

I am using wordpress and have added some js in a page and also I want it to be updated for the entire server testVar = "Failed" $("#someselector").click(function(){ testVar = &...
0 votes
0 answers
16 views

Help!!! Old theme doesn't load scripts and conflitcs with plugins

I need you help. I am using an old theme for some time. Now I installed two plugins WP Job Manager and AD Inserter but they are not working properly. Can someone give me a clue of what I can do to ...
0 votes
0 answers
29 views

WooCommerce Modal Fly cart on add to cart - With AJAX

I am trying to make a custom Flycart that can provide same functionality as the plugin 'WPC Fly Cart' Currently I have a modal div html element in my header.php, but how can I correctly trigger it and ...
  • 1
2 votes
1 answer
73 views

How to detect if we are in the Site Editor part of the Block Editor (as opposed to editing a Page/Post) in JavaScript?

We use JavaScript to unregister some Core blocks from the Page Editor. We'd like to unregister a slightly different list of blocks when using the Site Editor vs when editing a page or post. Rather ...
0 votes
1 answer
19 views

Can you customize the automatic permalink population on new posts?

I have a custom post type for events, I would love to intercept/change the JavaScript that populates the title to the permalink to have it also also use the date custom field (ACF) I have. Does anyone ...
  • 101
1 vote
1 answer
27 views

How can I show a Slot/Fill in the block editor

I am trying to render a Slot/Fill using createSlotFill from @wordpress/components. I have created a test extension using @wordpress/create-block and I have edited the Edit component like so: const { ...
  • 131
0 votes
0 answers
50 views

Astra Mobile Cart Drawer is blank on home page

I am using woocommerce and astra theme with elementor. I have a cart icon in my header menu which opens the cart on desktop. On mobile, it slides out a cart drawer (provided by Astra I think). On the ...
  • 33
0 votes
0 answers
80 views

Show Login Errors In Wordpress/Elementor (Code "works", but breaks site)

I customized my WordPress/Woocommerce account pages using Elementor and now they don't show error messages when users enter the wrong password, etc. I found this tutorial online that worked nearly ...
0 votes
1 answer
107 views

Remove Woocommerce product from cart with ajax/fetch

I have a problem with removing products from the cart in Woocommerce and I think it has to do with WC_Cart::remove_cart_item. I only get these error messages: POST http://localhost:3000/esport/wp-...
  • 3
0 votes
1 answer
39 views

How do I call an action hook into wp_ajax hook callback function

I have to trigger an ajax call based on a custom field changes on checkout form which is to add a discount. But if I call the hook to add discount into subtotal of the cart it does not do anything. ...
  • 44
0 votes
0 answers
39 views

Get all users from role and add to dropdown (select) - wordpress, javascript

I have a shortcode from functions, which retrieves a list of all users from active role. I have managed to get the list into the dropdown list with a little trickery if I wrap a div around the users ...
1 vote
1 answer
33 views

How to securely set dynamic HTML content with JavaScript?

Description I have implemented a frontend script that gets a few text options from the server via wp_add_inline_script. When the user does an action the content should dynamically change to one of the ...
-1 votes
2 answers
216 views

I want to display data last 7 days with date wise in chartjs?

Hello I am building simple plugin and i want to make a chart, I have used chartjs. Its displaying static data, I want label datewise. Example today 13-12-2022, So the lebel should start from 06-12-...
0 votes
0 answers
45 views

How To Include JS Script with WP 2023 Theme

I want to include this JS file / kit in my wp project https://sortablejs.github.io/Sortable/ (enables end-user to drag drop list items). Question: How best should I include this script using the ...
  • 153
-1 votes
1 answer
49 views

Is there a way to read JSON data inside Custom Fields without editing PHP? [closed]

I have a post with Custom Field called json_data, inside there is an array of strings such as: {"data":["string no 1","string no 2","string no 3"]}. Is there a ...
  • 101
-1 votes
1 answer
12 views

Select posts from list and add them in a new list

There is this fanduel website webpage with functionality to add players from left to selected players list in the right. Also when we click on filtering by position they are filtered without reloading ...
0 votes
0 answers
15 views

How can create a custom plugin to call my webapi after any registration or membership plugin functionality

I have a js function for registration . like this : e.preventDefault(); $(".error-alert").remove(); $(".success-alert").remove(); $(".submit-button&...
0 votes
1 answer
352 views

WordPress Ajax send response on every iteration of a loop

I am trying to get an ajax request to update the response as it goes through a loop, similar to a progress bar. A bit of background on this snippet. Here is the JS Ajax request: // ------------...
0 votes
0 answers
18 views

Losing Session ID and sessionStorage when navigating to other domains on Multisite

I'm working on a WP Multisite install with the following directory structure: The site on main-domain.com has navigation links that open the "ebar.com" and "efoo.com" sites (which ...
1 vote
1 answer
41 views

Use add_action to run a script, but only on the post editor page

My JS script runs on every page, but I want it to run only on the post editor page. function sm_validate_title() { echo " <script> console.log('script working') ...
0 votes
0 answers
9 views

how to embed a crop feature for cropping images uploaded by the user

I'm creating a newspaper website and want my user to crop the already existing image and download cropped images from the website. please Suggest me a plugin or javascript code for this. It would be a ...
0 votes
0 answers
41 views

Import js variables loaded via wp_localize_script() into js module without global scope connection

Assuming you have the following script with its variables that you enqueue as js module to a given page, via the following code in your main plugin file: wp_enqueue_script( '...
  • 421
0 votes
0 answers
21 views

comment_post function with js not running

I'm trying to import commenters details from WP into Klaviyo using the add_action('comment_post) but cannot get it to work when submitting a comment. I've run the function manually on a test page so ...
0 votes
1 answer
136 views

WP Rest API feature image breaking react component

I have a react app which displays posts by using the WP Rest APi. To display, I'm using map() to loop through the posts. {posts.map((articles, i) => { return ( &...
  • 127
0 votes
0 answers
34 views

Particle.js not loading in WordPress Gutenberg

I'm currently trying to teach myself how to design with Gutenberg (after previously only using Elementor), so I'm re-doing my website. I'm trying to have my hero section use particle.js but the ...

1
2 3 4 5
52