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

How to create a custom config file and get data using inline JS in a wordpress page

I'm totally new in WordPress as well as in PHP and making my first application with it. Currently, I use 'HTML block Element' to add content with custom HTML and inline Javascript code on blank ...
0
votes
0answers
19 views

Capturing variable after slash in domain

I'm developing an ecommerce website with Wordpress / Shopify API. I'd like to be able to capture discount codes through the URL. So if the discount code was code40, I'd like the enduser to be able to ...
1
vote
0answers
17 views

Contact Form 7 - Uncaught TypeError: wpcf7.initForm is not a function

I updated to WordPress 5.7 and Contact Form 7 v5.4. The new version is not compatible anymore with a js file (line 6 "wpcf7.initForm"), that a previous developer wrote for our theme. ...
0
votes
1answer
9 views

trying to put an active hover to my custom nav category buttons

I have a custom category buttons which each of buttons link and echoed the specific category at the same page. my goal is to put a active background hover color on the active link. here is my code so ...
0
votes
0answers
17 views

How to create a Toggle Navigation Menu for Mobile?

I have been trying to make Toggle navigation for which I have tried everything I could. There are some errors I am getting. Since I am using same navigation menu code used in desktop to show in ...
0
votes
1answer
34 views

Trouble with AJAX using GET

I am creating a event calendar. It works fine on our Intranet fine, but when I copy the plugin to an external site, I keep getting the following: Sorry, that didn’t work. Please try again or come back ...
0
votes
0answers
13 views

Woocommerce add products to cart

Is there a way to add a product to woocommerce cart without passing the product ID? So I have a DB with products and I do not want to import these products to woocommerce products in backoffice. Can I ...
0
votes
2answers
38 views

Gutenberg block don't save rich text content

I could not get to work. When published the content the attribute innerContent didn't save. Here is what I tried. block.js // Import CSS. import './style.scss'; import './editor.scss'; const { __ } =...
0
votes
0answers
10 views

Get admin css with javascript?

I need to take the "wpadminbar" color and put it as a background color for the plugin header. If the admin changes the color scheme the header color on my plugin also changes. Of course I ...
0
votes
0answers
14 views

Could be this a proper way to add script inline content to pages while in wordpress admin?

I used to include my inline scripts in the content of my pages, but many articles suggest to avoid that practice and rather include my inline scripts with functions like wp_localize_script(), or ...
1
vote
1answer
17 views

How to prevent XSS alter custom global javascript object & methods in Wordpress

Im working on a project in Wordpress that enqueues multiple .js files where each file adds a new method to a global javascript object, this in order to make the desired methods available only if ...
0
votes
0answers
18 views

Custom block SelectControl works but equivalent ComboboxControl gives errors - where's my mistake?

I have a SelectControl in a custom block, to set a meta field. It works, but would be better if it were a ComboboxControl, as the list of options is likely to grow, but I get errors when I switch it ...
0
votes
0answers
48 views

Adding URL hash to Isotope CPT filter

I've been able to get Isotope setup and filtering my custom post type content. My issue now is that I would like to be able to link to the filtered states using a URL hash. Effectively what is ...
0
votes
1answer
14 views

UnitControl - Block has encountered an error

I am trying to use UnitControl in my custom Gutenberg block to define the line-height of text. I receive the "This block has encountered an error and cannot be previewed" when I try to ...
0
votes
0answers
11 views

How to make AJAX Load More Posts on Scroll for custom theme and custom-post-type?

I am currently working on a project where I am coding a custom theme with custom-post-type called products. Now, I am coding archive-product.php and stuck at making an AJAX load more posts on scroll ...
0
votes
2answers
47 views

wp-env mysqlcheck error:1130

In Ubuntu 20.04 wp-env is giving me error once i have installed it and while trying to start it with wp-env start .The error showing is mysqlcheck: Got error: 1130: Host '172.29.0.5' is not allowed to ...
1
vote
1answer
23 views

Convert HTML Script to Shortcode [closed]

I want to convert this code into a shortcode from the Code Snippets plugin, I have seen an example come up but when I put it it does not work, the example is the following: add_shortcode( '...
0
votes
0answers
34 views

How to diagnose wp-env environment problem

Short version % node -v v14.16.0 % npm -v 7.6.1 % wp-env --version 3.0.2 % npx @wordpress/create-block foo ... Done: block "Foo" bootstrapped in the "foo" folder. % cd foo % wp-env ...
0
votes
0answers
13 views

How to show title and meta-data from one page to another dynamically?

I have been working on a project where it requires me to show custom-post custom-fields and title to show on checkout page as I click on 'make an order' button on single-product.php. Basically, I am ...
0
votes
0answers
11 views

redirect user when click anywhere on a page

I thought that when a visitor comes to my WordPress website if he clicks anywhere on the page, he will automatically open a new tab and be redirected to another website. And it will be only once after ...
1
vote
0answers
27 views

Gutenberg select categories

I have the following code wp.data.select( 'core' ).getEntityRecords( 'taxonomy', 'category' ); I get this error Uncaught TypeError: Cannot read property 'getEntityRecords' of null at Module../src/...
0
votes
0answers
29 views

Open href in a new window with onclick

I'm trying to include an onclick javascript inside php but I can't get it to work properly. The link will open in a new tab on the browser but not in a new window which is what the Javascript does. I ...
0
votes
0answers
22 views

Show popup on click

I have multiple categories on my wordpress site but few of them have large loading time, what should I do(the respective categories have multiple variations and images). Meantime I wish to publish a ...
0
votes
0answers
32 views

Cors headers Ajax

I'm just trying to run a basic jQuery ajax get request on instagram's api. $.ajax({ url:"https://www.instagram.com/page?__a=1", success:function(data){ console.log(data) ...
0
votes
1answer
22 views

Implementing a simple slider in code?

Here's where I'm at. Have inserted this into a page's html code: <div id="stgSlideshow"> <div> <img src="https://staging.retrorigs.co.uk/wp-content/uploads/2021/...
0
votes
1answer
27 views

Overriding inline !important CSS with Javscript code snippet with media query

There's a piece of inline CSS code: <style type="text/css" id="illdy-about-section-css"> #header.header-front-page {background-image: url(image.png) !important;} #header....
0
votes
0answers
11 views

How add attributes to all inner elements on first render?

this is a question from issue - https://github.com/WordPress/gutenberg/issues/29536 I created prototype which set tabindex to -1 for all inner elements, but its working only after nav has open and ...
0
votes
0answers
7 views

How to create post comparison in wordpress

I am creating a feature in the child theme which is vehicles(car) comparison. the checkbox will add the vehicles(car) in the compare list from the car listing page. and compare page will give the ...
0
votes
0answers
15 views

Dynamic Gutenberg Block Image Not Displaying

This is my first Gutenberg block using images and I can't seem to get the image to display. The text renders but it seems the image src doesn't work. const { registerBlockType } = wp.blocks; const { ...
0
votes
0answers
18 views

How to make toggle content from custom posts

I'm looking a way to toggle some content from custom post type. ex : https://vignerons-cairanne.com/fr/vignerons-cairanne/ I wan't something similar, when you click an image, it display the content ...
0
votes
0answers
26 views

Defer Parsing of “createjs.min.js” not working

I made an animation using Adobe Animate and embedded it in a html-widget on the website, while test.html and createjs.min.js are stored locally. html in the widget looks like this: <iframe sandbox=...
0
votes
0answers
15 views

WordPress site showing only text in browsers

My website started showing only text version in all browsers. I was removing unused css . In chrome browser it shows text version , but when refreshed it shows all the pictures . How I can find what ...
0
votes
0answers
16 views

Moving some buddypress scripts from head to footer

I have a buddypress installation and the bellow scripts are running in the head of my wordpress site by default wp-content/plugins/buddypress/bp-core/js/confirm.min.js wp-content/plugins/buddypress/bp-...
0
votes
0answers
16 views

Event listener not working in elementor

Event listeners work with a double click, not a single click. I create a custom toggle for show and hide functionality but the toggle not working with a single click.Please help I am a beginner in ...
0
votes
1answer
55 views

Conditional save return on Gutenberg Block

I am creating a "Trigger Button" or CTA button if you want to call it that way. The user can choose if it should be a download or a normal redirect. If it is a download, I want the block to ...
0
votes
1answer
24 views

Gutenberg select excerpt, use generated excerpt or use more block excerpt

I am trying to add the excerpt as a placeholder to a description field in the Gutenberg sidebar. The problem is that when there is no manual added excerpt the placeholder will be empty. Is there a way ...
0
votes
1answer
17 views

Google Tag Manager only load when connected to Admin

I've got this weird problem and I just don't know where to look : I've installed GTM tag on my wordpress site but it seems it's only being loaded when I'm connected as an admin. How I can tell ? In ...
0
votes
0answers
24 views

jQuery code not working in child theme JavaScript file [duplicate]

Added in my child's theme JavaScript File: $(function(){ $(".copyright").prepend("Yo!"); }); What's wrong?
1
vote
1answer
42 views

Using wp.data.select get actual tags (not id's) used in post

I am trying to retrieve the tag's used by the current post in the editor. Using the console from my browser; wp.data.select( 'core/editor' ).getEditedPostAttribute( 'tags' ) this will return the used ...
0
votes
0answers
11 views

Running JavaScript after using WooCommerce Filter Plugin

I’m using the Product Filters Plugin for filter products on my WooCommerce Store. I wan’t to do a complex design for the filter menu with JavaScript/jQuery but once I click on one of the filter’s ...
0
votes
0answers
22 views

Rest API and how to deal with it in server side

I'm developing a wordpress theme that uses REST API mostly. Normally I'm just creating a custom endpoint and pulling the data from that endpoint with vanilla JS's fetch. My problem is: I have a ...
0
votes
0answers
24 views

Uppload image from another source wp.media

I am writing an extension that will load images from third party sources and embed that image in WP media library. I cannot figure out how to manage wp.media to load such images. How it will work. ...
0
votes
1answer
41 views

Gutenberg sidebar show input field on toggle

I have been trying to learn about Gutenberg, React, ES5, ES6, Babel, Webpack JSX for the last few days. I must say it feels like I dove into some sort of wormhole... The only thing I wanted was to add ...
1
vote
0answers
12 views

Render blocking issue in google page insight

I found render blocking issue for css and js file plz need help to solve without plugin. I am using following code but it defer all js file. My webiste will break. How can i slove this issue function ...
1
vote
1answer
32 views

How to make custom total price reactive in navigation

I created navigation for my custom template and added total price inside the <li></li> elements and it show the price if I add product to the cart, but if I add another product to cart ...
0
votes
0answers
39 views

Using Google Analytics in an enqueued JS file

I have a JS file custom-head.js that I have enqueued to run in the header as noted in functions.php here: function enqueue_files() { wp_enqueue_script( 'head_scripts', ...
0
votes
0answers
17 views

how to make sure js is enabled before executing php function

I have a function that is in my post template and i need to make sure before executing the function that javascript is enabled. i have found a way using a cookie but it need to refresh the page twice ...
0
votes
0answers
14 views

Creating a POP Alert

I am using WPforms on a WordPress site. I have two checkboxes and you are only allowed to check one box. if you select two you get a warning you have exceeded the number of allowed selections: 1. I ...
0
votes
0answers
38 views

broken internal JavaScript and CSS files

there is more pages like this when i try to open any page i cant see the products and the wp-includes is not in that place i dont know why they trying to access from that path https://moroccan-craft-...
0
votes
0answers
22 views

Create a Wordpress Contact Form to call a POST AWS API Gateway and send user data

I am working for a company, and I need to create a Wordpress contact form to call an AWS Api Gateway with a POST Request, but the API function needs to get some parameters: Domain; SecurityKey (each ...

1
2 3 4 5
48