Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
11 views

Loading two different AJAX requests on two different pages

I hav ebeen trying to call two separate AJAX requests, on separate pages, each pulling in their respective parts. Right now, it only pulls in ONE of the AJAX requests on both pages even with specific ...
1
vote
2answers
17 views

Using Javascript for Looped Content

I have set up a loop to pull in staff bios. When a user clicks on the thumbnail of the staff member a popup with the complete bio information for that "post" should be displayed. I have been able to ...
0
votes
0answers
4 views

OMDB Api Jquery Autocomplete render problem [on hold]

I use omdb api to list the movies and used ajax inside ajax while doing this but having trouble doing rendering. What I want to do first is to list the movies with http://www.omdb.com/?s="movie-title ...
0
votes
0answers
7 views

Redirect user after form submit alert message

I need to display a javascript alert after a form submission and then redirect the user to the home. I have this code, but it will always redirect the user to the wp-admin/admin-post.php page. How I ...
0
votes
0answers
14 views

Javascript scroll eventHandler only working when I'm logged in in Wordpress

Trying to make a plugin in javascript. The code is working fine except the scroll event which only fires when I'm logged in Wordpress. The rest of the code (hopefully all) is working as it should ...
-1
votes
1answer
17 views

how do integration Carousel on Wordpress?

Get help from you how to place Carousel in this code that I have now: <div class="black"> <section class="t-grid-11"> <div class="t-grid-i"> <div class="t-grid-i-i"> <...
0
votes
1answer
14 views

Access post title from custom meta box on title change

I have a custom meta box as part of my post editor. When the user changes the post title, I want to reflect this change in the content inside the meta box. I have seen plugins like Yoast do this but ...
-1
votes
0answers
15 views

How do I make a div a specific size when doing an image gallery?

I am making a new custom plugin for my WordPress site that displays an image gallery using the shortcode: [galleryplugin] The plugin uses PHP and JavaScript. Essentially I want the shortcode to ...
0
votes
2answers
25 views

Cannot successfully execute AJAX script to call function.php specific function. Using XAMPP localhost to test

I've been trying to grasp AJAX for the past 12 hours and i'm slowly losing it. How can I simply pass two basic input dates via form or any other means, not refresh the page, and have it execute the ...
0
votes
1answer
22 views

How to properly add and access a JavaScript file in Wordpress?

I intend to use a JavaScript library on my WP website and have uploaded the JS file via FTP to the following directory belonging to the currently activated theme Salient: /public_html/wp-content/...
0
votes
2answers
26 views

Loading two versions of same JS libary

Currently migrating from an older version of a JS library (sweetAlerts), to a newer version. Both versions load, but I want to be able to use the updated library, but unsure how to reference it in ...
0
votes
0answers
9 views

Custom Java Script not working inside Guteberg editor

I try to add a custom java script to my wordpress theme using Gutenberg. In the frontend the scripts are working fine. In the backend (gutenberg) the scripts are included but not taking any effects on ...
0
votes
1answer
35 views

Accessing javascript in multiple files

in order to access jquery with a $, I am wrapping my Javascript file in (function($){ ..... })(jQuery); This works fine, but I would like to add another javascript file which contains functions ...
1
vote
0answers
16 views

Gutenberg: import dependency or assign from global variable?

When developing for the Gutenberg / block editor, I see two methods used in various resources. Let's say I wanted to use i18n The Gutenberg handbook sometimes does it like this: Define wp-i18n as a ...
0
votes
1answer
22 views

sessionStorage saves input value in browser but it is not loaded in the form field

I am trying to save the input value of form fields but only one of the fields returns the value on page refresh. I can see the input value of the second field in sessionStorage in chrome but it is not ...
0
votes
0answers
12 views

Get String returned by function get_the_title () and show it in Metabox without clicking on “Update” or “Publish” Button

I have the following code in my functions.php that shows or replicates the same text in Capitals of the "Title" field of a WP entry, in a Metabox that appears when the same entry is edited. ...
0
votes
0answers
14 views

Collapsible menu on post sidebar only expands and does not collapse

I'm working to improve an existing wordpress theme that was built for my organization. I've run into a problem that I'm not familiar with: the archive menu displayed on each post will only expand, but ...
0
votes
1answer
10 views

XMLHttpRequest of admin data to public

I have a function that get the data from a admin page and display the result at frontpage. But only works when admin user is logged in. How can I display the result even if user is not logged in? ...
1
vote
0answers
26 views

When using the block.getSaveElement hook can you output different markup based on whether or not you are in the edit view or the live page view?

I am trying to extend the core/image block to add an option for a deferred image. I want to replace the src attribute of the image with an empty string and add the url as a data attribute to be loaded ...
1
vote
1answer
17 views

Get Block Attributes in JSON REST API

I am trying to make my block attributes show up in the REST API. To start, I've added the rest_api_init hook to whitelist my block for inclusion. add_action( 'rest_api_init', function () { ...
1
vote
0answers
23 views

Is there a standard way to listen for an on change event of a posts featured image

I'm working on an artist plugin which lets you upload/create a depth map image for jpg's in your media library. To do this, I created a custom meta box which lets you draw the depth map using canvas/...
-1
votes
1answer
18 views

Mobile menu will only toggle on

I've got a mobile menu that will toggle on, but it just won't go away. my JS: const menu = document.getElementById("mobile-menu"); const button = document.getElementById("navButton"); button....
-1
votes
2answers
36 views

Don't understand how to link Javascript files in Wordpress

I'm trying to run some simple javascript on a button click but I can't seem to find clear instructions on how to set up Javascript to run in wordpress. The steps I've taken so far are to enqueue the ...
-1
votes
0answers
22 views

How do I replace a nodeJs home page of a website with a word press page as index page?

The present website has the following stack Scripting Language: Node Js Content Management System: Custom Client Side Scripting: JavaScript, Angular JS Database: MySQL Web Server: Apache Operating ...
0
votes
1answer
26 views

jQuery for Fade Preload Causes My Site Favicon to Disappear from Tab of Browser

My website's favicon that is seen in tabs of chrome disappears when i use the following jQuery. Removing this script from head makes the icon visible. But why a seemingly simple and unrelated code ...
0
votes
1answer
27 views

shortcode execution when the page is opened

Is it possible to have a link to a page in my website trigger a shortcode button without leaving the home page! I have a shortcode button that activates the ordering process for the customer but I ...
1
vote
1answer
114 views

Gutenberg Modify core taxonomy panel element via wp.hooks.addFilter

I’ve researched modifying an existing editor element… and there’s little out there. But I did get a good reply at Github that pointed me to this: https://github.com/WordPress/gutenberg/tree/master/...
0
votes
2answers
78 views

Cannot set property 'className' of null at setThemeFromCookie

I am coding in WordPress to make a button to toggle body class from light-mode to dark-mode. i was experimenting with trying to add a cookie so that the preference is remembered for the browser. But i ...
0
votes
0answers
14 views

Wordpress plugin works only on Home Page? WP Bodymoovin

I am using WP Bodymoovin plugin and it works properly only on the main page. In all other pages is not working properly, doesn't load the animation and gives me that error: lottie.min.js?ver=5.2.1:...
0
votes
0answers
18 views

Make CSS active on Plugin admin page work on any site/page/post

I currently have a nice css file hooked into my /wordpress/wp-admin/admin.php?page=Iformbuilder_create page but I'd love for the CSS to stay on the form that's created even when used on other sites ...
0
votes
1answer
26 views

WP Gutenberg - custom block with two content fields

I'm developing Gutenberg custom block for accodrdions on my website. My code was working with only one content field. When I have added second props it has stop worked and console says: Cannot read ...
0
votes
1answer
28 views

Load script after block is inserted

I have created a map block plugin that works more or less, but I'm having trouble understanding how to load the map script when/after the block is inserted. If I reload the page after inserting/saving,...
0
votes
0answers
34 views

Javascript working on jsfiddle but not wordpress site?

This is the code that I want to include on wordpress site: http://jsfiddle.net/EFM9b/1/ The results doesn't display on wordpress site, but it does work in JSfiddle
0
votes
0answers
16 views

How to force all non-Admin links in the Admin console to open in a new tab?

I prefer to never lose my Admin view. If I click on a link in the Admin and it goes to another part of the Admin (e.g. New Post), great. But if a link goes either to my site's front-end or to an ...
0
votes
1answer
15 views

currentURL is not defined

I'm using Woocommerce with Sensei. When I go to Checkout the payment method keep loading with spining and don't let me finish the payment. In the console I get the error: Uncaught (in promise) ...
1
vote
1answer
36 views

Automatically append ID to at the end of specific URLs

I need to be able to automatically change normal links to affiliate links on my Wordpress website. For example: when I add a GOG.com link, it should automatically append my partner ID at the end of ...
0
votes
0answers
22 views

Javascript Tooltip not fully working on my wordpress page

I'm trying to implement the following bit of code to create a hover tooltip that follows the mouse: https://jsfiddle.net/mgbv5tzx/212/ I've implemented it on my wordpress page, exactly as in the ...
-1
votes
2answers
22 views

Load css classes after using ajax calls

I wan to add a responsive div to my wordpress page using bootstrap css, just when i enqueued bootstrap style it distroy themes, so i wan to make that div load using ajax call, call that enqueued style ...
0
votes
0answers
20 views

Drodown list return issue

I made a function that doesn't work properly: it correctly returns the slug of the selected tags except the first one in the list. Someone can help me understand why please? The code is below ... ...
0
votes
1answer
28 views

Wordpress 5.1 upgrade has lost the parent theme JavaScript

I have just upgraded from Wordpress 4.9 to 5.1, which obviously comes with Gutenberg. One major problem I have is that the parent theme (BeTheme) JavaScript is not being loaded and instead the child ...
0
votes
0answers
9 views

Got a TypeError after update and need to adapt found solution

I've recently updated my WP and I'm getting this error: TypeError: switchEditors.switchto is not a function I've found this: This is due to changes to the core in Wordpress 4.3+. You need replace ...
0
votes
0answers
14 views

Difference between using js code referred to earlier and defining the source in the meta of the <script> tag?

sorry if the title is not too self-explanatory, I couldn't find a better title. I am including "bootstrap-select" in my wordpress installation. If I enqueue the script and later try to use it I get ...
0
votes
0answers
47 views

How to Clear PWA cache when user Logs in or Logs out with SW

My site shows different content for logged in user and logged out user. The PWA troubles because the aggressive service worker cache shows logged out user content even after user logs in. Is there ...
0
votes
2answers
24 views

How to execute WP shortcode in a javascript string “”

I would like to insert and execute some WordPress shortcode through main.js file, in a string "", but the problem is that it won't execute! Here is an example of my main.js: .. }, "March 6": { "...
0
votes
1answer
65 views

Enable right click on WordPress site

I can not right click on my site and I don't know why! Is there any function to enable right click on the site?
0
votes
0answers
17 views

Vue js not working in WordPress Widget

I am trying to use Vue js in one of my widget. There are select, input fields in the widget which is inside form() function. But the code is not working, there is no error on console as well. Button ...
1
vote
0answers
14 views

Setting/unsetting terms using the Backbone JavaScript client

I'd like to set and delete terms in my custom taxonomy using the WordPress Backbone JavaScript client, which provides access to the REST API in JavaScript. I can't find an example or suggestion in ...
7
votes
1answer
51 views

Proper, exhaustive documentation for wp.editor etc

There exist the following : wp.editor.PanelColorSettings wp.editor.InspectorControls wp.editor.RichText wp.editor.BlockControls etc. Where is the documentation that shows the full list of available '...
0
votes
1answer
21 views

How do I make a savable preview like Youtube Gutenberg block?

The Youtube Gutenberg block makes you enter a Youtube Url, then shows the video... until you select it and select "edit" on the toolbar, see the url and change if you want. I understand the edit ...
0
votes
1answer
14 views

Replacing entire tag with shortcode - JavaScript [duplicate]

I'm trying to replace a whole tag with a shortcode, if the tag text equals a value. I'm placing this script into the footer of the page. Here's what I'm trying: var stockcounter = document....