Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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
0 answers
13 views

How to get selected variation from URL?

I create my own way of displaying the list of available variants on the product page. I display individual variants on the main page of the store so that when the customer goes to the product page, he ...
patryk siuta's user avatar
0 votes
0 answers
45 views

Malware detected in my Wordpress in theme.php [closed]

I have a javascript malware rogueads.unwanted.ads?32.2 detected by Sucuri. It permanently generates the files "wp-includes/widgets/crypto.txt", "wp-includes/widgets/include.php", &...
Lungu's user avatar
  • 1
0 votes
1 answer
63 views

Calling a function via a shortcode in javascript

I'm looking to dynamically change the page-comments option based on whether the user clicks a URL. I have two functions to do this: function psb_comment_listener_func(){ echo " <...
pbee's user avatar
  • 5
0 votes
1 answer
11 views

How to apply a javascript code on certain parts of elementor made pages?

For example I have a simple animation which decreases the menu height and font-size while scrolling. <html> <head> <script> document.addEventListener("DOMContentLoaded", ...
inf3rno's user avatar
  • 135
0 votes
1 answer
32 views

Escaping inline JS correctly

function test_dashboard_content() { $args = array( 'posts_per_page' => -1, 'post_type' => array( 'post', 'page' ), 'post_status' => 'publish', 'date_query' => array( 'after' => '1 ...
WPdummy's user avatar
  • 23
0 votes
1 answer
14 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
26 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
0 votes
0 answers
36 views

Localize javascript files for translation

I have several javascript files added to a child theme. I need to localiza those scripts in order to make them a vailable to treanaslation to other languages. I've already done it for the php files. ...
GKaplan's user avatar
1 vote
0 answers
18 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
3 votes
1 answer
45 views

How to add group-row to InnerBlock template?

We are trying to add a group-row to our InnerBlock template. Now there is a core block called core/group which works when being inserted. The core/group has variations as group-row. But when inserted ...
user241943's user avatar
0 votes
0 answers
26 views

add_attachment hook not firing on certain devices

I am developing a plugin for a client, and we are using the add_attachment hook to extract metadata from the images that we process as part of the plugin. The funny thing is that the hook successfully ...
John Doe's user avatar
  • 287
0 votes
0 answers
10 views

Retrive the value of the Active variation of the product and then link it to the "read more" to dynamically change

Here is the code snippet where Only the tab-description is attached to the "Read-more". How to make it dynamically change based on the current active value of the Variation - material ...
Teresa's user avatar
  • 1
0 votes
0 answers
16 views

Can't make an external api call in php side of wordpress child theme

I'm new to making api calls in wordpress. I need to make an api call through the backend to a 3rd party api. I can't do it through the frontend because the 3rd party makes it so I get a CORS error and ...
vroque2022's user avatar
0 votes
0 answers
20 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
0 votes
0 answers
16 views

Additional CSS classes not being added in Gutenberg editor

When we add additional classes to our custom block they are not being added in the editor. When we save the block and view the front-end the additional classes are showing. But in the editor they won'...
user241943's user avatar
0 votes
0 answers
13 views

Sudden ERR_HTTP2_PROTOCOL_ERROR on every JS and CSS files loads

I recently went on my website which is online since more than 5 years now and realized that none of the CSS and JS files were loading. By looking into the console, I’ve seen that every load fails ...
CesMRY's user avatar
  • 11
0 votes
0 answers
17 views

allow multi carousel in same page

I have this code for slider, i need help to edit it to allow multiple slider in same page. var all_divs = $('.px-carousel-container .px-carousel-item').length; var i = 0, n = 0; let ...
user3418508's user avatar
0 votes
2 answers
113 views

window.location.href doesnt' work to redirect page

I am trying to add a custom HTML block to the page with the below code. I created a Drop-down List and a search button for redirecting pages. But it seems like that window.location.href doesn't work ...
Leanne's user avatar
  • 1
1 vote
0 answers
60 views

slider i want move 4 images every button click

I have this code for slider button, i want move 4 images every button click. and make the button not active when all images slides if right or left. (sorry if my English not good) $(document).on('...
user3418508's user avatar
1 vote
0 answers
10 views

can not serialize and insert data from custom form

I have a custom form . My form have three input fields book_name, chapter_title and chapter_content. chapter_title and chapter_content are dynamic form fields. I want to insert book_name as post_title ...
Khalid Saiffullah's user avatar
0 votes
0 answers
7 views

How can i force replace a external js scripts language on the site itself?

Im using this https://www.gloriafood.com/ service and their translation is very poor. I would like to make adjustments myself. since it comes from an external source i cant really edit any spesific ...
Leo's user avatar
  • 1
0 votes
1 answer
24 views

Why does my JavaScript work in the browser console but does not work in my shortcode?

I am trying to create a shortcode the user can just insert which creates a button that loops through an array and displays it or hides it. On page load I want every item with an index >= 1 to have ...
rnkwill's user avatar
1 vote
1 answer
31 views

Metabox conditionals depending on post format and template in Gutenberg

In the classic editor, I used jQuery to display metaboxes depending on the current post-format or page template selected. If a user selected a different format or template, they would toggle depending ...
kath's user avatar
  • 611
0 votes
1 answer
35 views

How do I filter/modify the updated content on save using javascript?

I want to use js to filter content being saved in the Gutenberg editor for pages. So far I have this, which will get the content on save, but let's say I want to append xxxxxx to the end of the ...
user18102663's user avatar
1 vote
1 answer
110 views

Update a server-side render Block when woocommerce cart block changed

I am currently developing a small block for WordPress/WooCommerce and now I have a problem that I can't solve easily. To summarize: I am looking for a way to update my block in the frontend when ...
HackePeter's user avatar
0 votes
1 answer
44 views

How to detect changes in WooCommerce store (react)?

Since WooCommerce merged blocks in the plugin, the cart is now completely 'reactified'. Meaning I update the quantity on my cart, I see a network call to an endpoint, thigs update without reloading, ...
dingo_d's user avatar
  • 1,950
0 votes
0 answers
18 views

Passing total post count to javascript

I have a ajax post loading program, I can load more post on click of a button. Problem im having is getting the button to hide or show less when no more post. I can query out the post count in PHP as ...
Beep's user avatar
  • 29
0 votes
1 answer
14 views

get total post in category via ajx

Aim The total to be equal to the amount of post within the selected category or sub category. What im getting I am getting 0 when trying to get the number of post available in a category. My aim is to ...
Beep's user avatar
  • 29
2 votes
0 answers
34 views

Can't find elemnts on the DOM using Custom Control in Customizer API

I'am creating a Custom Control on Customizer API, I add Multiple Checkbox as my custom type. When I wanna add a live preview, the jQuery doesn't find the selector that I want. Here's functions.php ...
Miminou's user avatar
  • 21
1 vote
2 answers
204 views

How to re-render Gutenberg component when object instance is available

I'm working on a Gutenberg component that displays a grid of images using the core Masonry library (some code omitted for brevity): const containerMasonryRef = useRefEffect((element) => { var ...
leemon's user avatar
  • 1,918
1 vote
0 answers
11 views

WP Bootstrap NavWaker: Dropdown Menu Opens All Dropdown Menus at Once

I'm having difficulty implementing a dropdown menu with Bootstrap and WordPress. I've used filters to add the 'dropdown-toggle-split' class to the link elements of menu items that have submenus. ...
Hendra's user avatar
  • 15
0 votes
0 answers
37 views

Need help understanding Minimize main-thread work

i'm doing a pagespeed test for my site and the main error for mobile is: Minimize main-thread work 8.4 s Consider reducing the time spent parsing, compiling and executing JS. You may find delivering ...
Ruby's user avatar
  • 1
1 vote
0 answers
17 views

Wordpress Plugin, Elementor and the ReferenceError nightmare

I have a wordpress plugin for a third party site I run. I runs in conjunction with the standard text editor module used in pagebuilders (Beaver Builder, Divi, Elementor, etc), but for some reason, it'...
Ben J's user avatar
  • 11
1 vote
1 answer
59 views

How to use Javascript to get data from a Wordpress form

I'm building a booking form using WS Form in Wordpress. Because of the several calculations and conditions accuring when selecting the number of people partecipating in the booking, the form is crazy ...
Paolo Montalto's user avatar
0 votes
0 answers
23 views

Default post showing more than intended

I have a ajax set up where I am loading post categories via ajax request on click of a button. I have a default query that is loaded for when the ajax filter is not set so a default state. It should ...
Beep's user avatar
  • 29
1 vote
0 answers
59 views

Ajax load more post button not showing

I have some alpine.js and ajax that is loading wordpress posts on click of a button, this is working well. however I am now trying to add some code to the button to hide if no post available to load, ...
Beep's user avatar
  • 29
0 votes
0 answers
27 views

Load more post with AJAX

I have a simple post that i am using alipine.js to help me load post using AJAX. So far it is loading my pages and changing the category if I click a filter button, this is all expected and working. ...
Beep's user avatar
  • 29
0 votes
0 answers
22 views

how to assign javascript variable value to php variable in wordpress

I use following way to fetch the value of gtag if it already exists in the code: <script> const regex = /googletagmanager\.com\/gtag\/js\?id=([^\s'"]+)/gi; const ...
ahmedwp's user avatar
  • 21
2 votes
1 answer
289 views

How to add an additional dependency to a block index.asset.php file

I have a plugin that registers four different Gutenberg blocks. I build them using the build script from the wp-scripts package. As you all surely know, this script automatically generates an index....
leemon's user avatar
  • 1,918
1 vote
2 answers
83 views

Post current post type to my Ajax

I have two files, alpine js and a ajax, i want to get my current post type from wordpress with $post_type = get_post_type( $post->ID ); $postType = get_queried_object(); $args = array( '...
Beep's user avatar
  • 29
1 vote
1 answer
101 views

useSelect() plus resolver result is serving cached data incorrectly

Well ok, it's probably not incorrect that the data is cached, but it's not what I want to happen. But I am stuck on how to correctly set up my custom data store the way I need. I'm trying to set up a ...
helgatheviking's user avatar
0 votes
0 answers
40 views

JQuery UI Autocomplete showing as bullets

The JQuery UI Demo page for autocomplete has a nice looking search box and drop down. When I implement it in my plugin, I end up with a bulleted list. How do I get my drop down of suggestions to look ...
Tuba Saif's user avatar
0 votes
1 answer
149 views

Insert text programmatically in WordPress Gutenberg Editor

What's the correct way to insert text (or modify existing, selected text) in the Gutenberg rich text Editor? I have a button/menu choice added to the drop down menu to the right of the "Link"...
joho's user avatar
  • 53
0 votes
2 answers
30 views

Processing javascript on wordpress

I'm working on this project where I want to add some html on my wordpress website. The point is to add a "read more" button. Here's the code: <p>some text<span id="dots"&...
PJaze's user avatar
  • 1
1 vote
0 answers
32 views

Why jquery arrray return 0 value

The array in this function return 0. I am unable to figure out what the problem is. function custom_woocommerce_auto_suggest() { $search_query = sanitize_text_field($_POST['search_query']); $...
Tuba Saif's user avatar
1 vote
1 answer
37 views

Translating the "Everything" filter menu in Quicksand jquery file

I have been using QuickSand Jquery to display my WordPress portfolio. Everything is working well. I just added the polylang plugin and would like to be able to translate the first item of the filter ...
made leod's user avatar
1 vote
1 answer
32 views

enqueue_custom_scripts isn't working

I am attempting to use javascript to activate hotpots I have made in Wordpress, (using HTML and CSS but when trying to enqueue my custom script. Nothing is happening. function ...
CiaranQM's user avatar
0 votes
0 answers
13 views

Woocommerce product search result page layout

I am creating a custom search bar with a category dropdown in my woo-commerce site so how do I fetch the exact design(HTML, CSS) of products in my search result as I am getting through shortcodes like ...
Tuba Saif's user avatar
0 votes
0 answers
28 views

JQuery UI Autocomplete/Autosuggest Wordpress

I am creating custom search bar with category dropdown in my wordpress woocommerce site but auto-suggest not working showing response array 0 in console.What's wrong with the code? I am a beginner i ...
Tuba Saif's user avatar
0 votes
1 answer
398 views

How to optimise Text to HTML ratio for SEO by separating the HTML into multiple files?

I have run into an issue with my Wordpress/Elementor site and I hope you guys have any advice. I did an site audit with Semrush, and as it turns out the ratio of text to HTML is only 1-2% but it ...
Robert's user avatar
  • 1

1
2 3 4 5
54