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
10 views

Get data from PHP to JavaScript to set position of each post on front page

I've created a custom post type called project for my Wordpress theme, which works fine. Each project has several custom fields, including a set of x and y values that indicate where the project ...
1
vote
1answer
246 views

How to search using ajax for exact phrase or words in an input field?

I have been following this and it works almost perfectly but it is not only finding the title posts with the same words as per what we write in the input field but it finding ALL posts regardless. ...
2
votes
1answer
17 views

conditional layout based on if Innerblocks is not empty

This seems like a simple issue, but I can't seem to find an answer. I'm using InnerBlocks to stack some paragraphs in a wrapper. If there are no blocks set I'd like to not output the wrapper at all. ...
0
votes
0answers
10 views

Call javascript function when add_attachment hook fires

I want to run a javascript function when the add_attachment hook fires. The following code does not interfere with uploading an image. add_action('add_attachment', function( $post_ID ) { ?> ...
0
votes
1answer
6k views

Ajax page load without reload

I am working on a script to load my page without refreshing. It is working as I want it except for one thing. The test site I have up is http://dev.dog-company.com . Only home About us and FAQ will ...
0
votes
1answer
12 views

My scripts-bundle.js file is getting sent to the browser as a stylesheet css file. Help!

I'm new to WordPress custom theme development. I am using a child theme for OceanWP. I have a webpack setup to hot-reload my files but my js scripts are not getting sent to my WordPress site instead ...
0
votes
1answer
9 views

WordPress custom post type post item data - show/fetch only on click with Javascript dynamically?

I have a question. Hopefully, I will be able to explain what I am trying to do here. I have created a custom post type "Feeds" and published 10 post types inside that CP. Now, usually, I would just ...
-1
votes
0answers
6 views

There is a way to split woocommerce-new-order in two different account if an option is selected?

i'm looking for a method to split woocommerce new order email in two different email account when it's selected an option to billing section. There is an example: If I select option 1 in dropdown ...
0
votes
1answer
11 views

Ajax Comment Upvotes - Votes don't always register

I'm trying to create a simple ajax-based comment upvoting system for Wordpress. I've managed to build most of it, but now it seems that most of the time the upvotes don't register. They do register ...
0
votes
1answer
386 views

Hide Add to Cart Button

I am using a plugin to help "build" a customized product. There are different tabs/steps the user has to go through with back and continue buttons. At the last step I would like to add an "agree to ...
2
votes
2answers
84 views

creating elements/innerblocks via rangecontrol

I'm attempting to put together a variable/mixed content carousel block. I'm having issues trying to figure out how to create/delete individual slides in the carousel (using something like rangecontrol)...
1
vote
1answer
52 views

React JSX in Wordpress Plugin Development

I was able to get React working in my custom Wordpress Plugin but I forgot how I got it working. What I'm trying to do is use a react component I have in NPM and use it as a Wordpress plugin. I used ...
0
votes
1answer
29 views

Where is the Javascript attribute window._wpCustomHeaderSettings defined?

I'm trying to modify the behaviour of the Javascript function defined in wp-includes/js/wp-custom-header.js, to change the minimum windows height to display a video header. For this, I need to modify ...
0
votes
1answer
11 views

Changing the default view of “The Events Calendar” for mobile

I'm using "The Events Calendar" plugin on my site at https://divealaska.net/events/. I’m looking to set the default view to List but only for the mobile. So far I’ve come up with trying to add a bit ...
7
votes
1answer
705 views

Set default image link target in Gutenberg image block

I want to set the default target of the image block in Gutenberg to "Media File": I've found solutions for the classic editor, and one that appears to work for Gutenberg galleries by editing the ...
0
votes
1answer
449 views

oEmbed Video in Modal

I'm attempting to use jQuery to open up a video in a modal but can't come up with a way to pass the oEmbed video url to the function which opens the modal. In my theme the user adds the video to an ...
3
votes
2answers
5k views

Wordpress Infinite Scroll without using any plugin

Background information can be skipped. I wanted to use the infinite scrolling option on my Wordpress theme, but I am not well trained in Javascript so I tried this solution: https://wptheming.com/...
1
vote
2answers
17 views

Calculate price and display on woocommerce product single page under price (simple price, variable price) [on hold]

I am planing to show a new price on my woo-commerce product page for all products. This is the installment price per month. I need to show this below the normal price (variable price and simple price) ...
1
vote
1answer
2k views

How to Dynamically Load Content Into Body of Bootstrap Modal Window?

I found this answer on Stack Overflow, answer this exact question. I've modified it slightly, because I'm using a button and not an anchor: jQuery( ".modal" ).on( "show.bs.modal", function ( e ) { ...
3
votes
1answer
12k views

Comment form validation

How can I set the validation rules for the comment field? I change the value of commenter name/e-mail/homepage onmouseover and onblur (I use this instead of labels - so if the field is empty it ...
0
votes
0answers
16 views

Registration bug ClassifiedEngine [on hold]

I'm using a modified version of ClassifiedEngine on my WordPress installation. Since tuesday we are having the following error when someone clicks on our (custom front-end) registration form, which is ...
0
votes
0answers
17 views

how to disable mouse wheel scrolling? [migrated]

I need to disable mouse wheel up-scrolling on my site; Tried the following js code, but it didn't work. $(window).on("wheel mousewheel", function(e){ if(e.originalEvent.deltaY > 0) { e....
0
votes
1answer
757 views

Redirect sub-page URLs to parent without changing URL

I am having an issue with redirect rules for a single-page app that is on a sub-page of a Wordpress site. I have followed this set of instructions pretty directly and am still having issues: Redirect ...
0
votes
1answer
27 views

Page from parent menu is not opening [on hold]

What is happening? The link of parent menu is ok, but it does not open the site and the menu is closed. Goal: It should open the page of the parent menu. I found this. wp_bootstrap_navwalker.php (...
0
votes
1answer
500 views

How to echo a PHP code into WooCommerce variation product?

I have a little complex to explain the problem which I hope someone can understand and help me with. I have set custom fields on WooCommerce which I use to enter a specific code for each product (...
0
votes
0answers
7 views

Whole section scroll - issue with scrolling - Divi [on hold]

I have a problem with the project. On the page I used scrolling whole sections - each section is 100vh and scroll jumps to the next one. Theme: Divi (current version) WP: 5.2.2. JS used to scroll: ...
0
votes
1answer
662 views

How do I add JS and CSS to WP (Flatsome)

I have a codepen that I would like to import into my WP setup. It is an expanding column layout, which includes custom CSS and JS. Link here: https://codepen.io/thedonquixotic/pen/WGYXyd Now, I have ...
1
vote
1answer
23 views

Get loading state of wp data selector

I have a custom block that shows the assigned taxonomy terms for the current post. I'm trying to show a loading spinner while those terms are loading in the background. Let's say I have a selector ...
0
votes
0answers
8 views

Select Menu to Other Select Menu

how to select a menu for a hidden menu with display: none; <select id="help-comradeso[]" > <option value="1">Janeiro</option> <option value="2"&...
2
votes
2answers
2k views

Enqueuing Script in functions.php vs on the page

Does it matter if I enqueue a script on just the page I need it to be used? As opposed to functions.php? Or, what is the best practice? In this example I need a rotator just on the front page of my ...
0
votes
1answer
398 views

Help wiht adding fullcalendar.io to a WordPress page

I've been trying to add this calendar to my wordpress page. And I've followed the documentation, but it's still not showing up. This is what I've done. I first added this to my child theme functions ...
1
vote
1answer
472 views

Add code to WordPress menu items by class

I am trying to add onclick="toggle_visibility('sub-menu');" into the opening tag of specific menu items generated in WordPress. I have used the following function to target all parent menu items ...
0
votes
1answer
19 views

Get user in rest API endpoint

I'm making some API endpoints that require me to confirm who the user is, and what they can do, before I let them use the endpoint. However, I can't seem to get the current user. My endpoint: ...
0
votes
0answers
12 views

Why aren't my custom js scripts loading from child theme?

I'm trying to override some custom js files in my child theme, and I have managed to get almost all scripts working, except for one script - the 'child-listing' script. All scripts load from child ...
-1
votes
2answers
123 views

Adding react app to an existing wordpress website

I have built a react app and I want to add it to my existing wordpress website. So basically when you visit mydomain.com/reactapp you should see the app. But for now I am getting a white page and in ...
0
votes
0answers
20 views

Select value in tab [on hold]

The JavaScript below works perfectly. But when I change tab it doesn't work! Thank you very much in advance. <button id="toggle" name="test" onclick="myFunction()">on</...
1
vote
1answer
2k views

Button not refreshing page

I'm creating a WooCommerce site where the archive page shows products related to the city the user is interested in "London" or "Manchester. On the /shop page of the website I've created a banner ...
1
vote
2answers
393 views

Rhyzz Repeatable-fields javascript in php and wordpress

I'm having a hard time figuring out why my repeatable fields javascript doesn't work. I'm using the following plugin: Rhyzz (repeatable-fields): http://www.rhyzz.com/repeatable-fields.html. I scraped ...
0
votes
0answers
27 views

Looking for callback function after Gutenberg is rendered?

On post/page editing screen, I want to call my functions as soon Gutenberg editor/whole page is fully rendered and visible. On WP 5.2.2, I have tried jQuery(document).ready(function () {}); and wp....
1
vote
1answer
419 views

Call post-id from URL hash not working?

I'm trying to have a modal box open by default when calling it by its id. For example, if i enter the url www.mysite.com#post-28 (#post28 being the ID of the post) I will land with the moadal box ...
0
votes
0answers
5 views

How To Have a Image at Center of SVG circle of Scroll Progress Indicator [migrated]

I wanted to Create a scroll progress indicator, to show how much have i scrolled on a page. I prefered a svg circle, with stroke, that completes at full scroll. I found it easily here But then i want ...
0
votes
2answers
26 views

Modifying child theme's header

I'm a noob. I have copied the header.php from the parent theme, I have added some snippets and things work. However, I would like to be able to add those same snippets either using a plugin or via ...
0
votes
0answers
9 views

.outerHeight(); getting decimal value? [migrated]

It is possible to get a decimal value of .outerHeight(); Right now it's returning a rounded value. $(window).resize(function() { var div_height_2 = $(".home-row-3-1").outerHeight(); $...
-1
votes
1answer
21 views

FacetWP: Plugin breaks button/modal functionality inside searchable content area

I am currently testing the FacetWP trial with two facets on a post archive page, using the WP-show-posts plugin for displaying posts and modal-video.js (https://github.com/appleple/modal-video) for ...
0
votes
0answers
18 views

Customize gutenberg columns block css name

Hello, I start to learn how to use Gutenberg in these last days, but I'm bit confused. I want to try to customize all the classes in the columns block for make the html layout ready for Bulma. This ...
0
votes
0answers
12 views

Avada theme not rendering embedded code [closed]

I'm trying to embed code for a form created in another system. This loads just fine in another wordpress site (built with Elementor, not Avada ThemeFusion). This leads me to believe the issue is with ...
0
votes
0answers
14 views

Is there an option to execute javascript file only on plugin deactivation

I'm creating a custom plugin for WordPress and I'm trying to execute javascript file only on plugin deactivation. I'm using register_deactivation_hook() and wp_enqueue_script() to execute file only ...
0
votes
1answer
27 views

AJAX update fails for public/non-admin users

I've built a function which, depending on the submitted option in a <select> input, generates a new data table (TablePress plugin) and inserts it into the page via AJAX. The function works ...
0
votes
1answer
407 views

Help with my first Metabox helper class

I'm working on a metabox helper class and everything works well, but the radio image field. The images show up, but they aren't clickable. // Print radio_image input. private function ...
0
votes
1answer
412 views

Relative path instead of absolute for wp_enqueue_script

When you enqueue scripts or styles with the following: function themeslug_enqueue_style() { wp_enqueue_style( 'core', '/style.css', false ); } add_action( 'wp_enqueue_scripts', '...