Questions tagged [ajax]

Ajax - The core of WordPress uses Ajax only in the administration screens. For instance, Ajax is used for instant updates when you are doing comment moderation, and when you are adding and deleting items from lists such as categories, blogroll, and posts; Ajax is also the technology behind the auto-save functionality on post and page editing screens. Several themes and plugins also use Ajax; for instance, some post rating plugins.

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

Wordpress Insert line in DB when clicking a button

when clicking buttonHdp, I wold like to launch the php code in order to insert a line in DB. Script <script> document.addEventListener('DOMContentLoaded', function() { jQuery(function($){ ...
Jean-François Moulin's user avatar
0 votes
0 answers
13 views

How to show custom fields in modal in category page

The code below shows the title and content in the modal popup in category.php file. The full tutorial can be seen here although not important: https://artisansweb.net/load-dynamic-content-on-bootstrap-...
user3362364's user avatar
0 votes
0 answers
31 views

Applying a custom query for the AJAX "us_ajax_grid" function (from WPBakery)

I have some custom queries that are working properly with pagination if I use the regular pagination numbers, but I want to use the pagination as "page load on scroll" and then apply my ...
Pedro's user avatar
  • 33
0 votes
1 answer
15 views

Cannot get user's ACF data when using a template part in a WP_User_Query

I'm using a template part to repeat the HTML for each result when performing a WP_User_Query to return a list of users. However I am finding that the Advanced Custom Fields data isn't returning. // ...
greatsplott's user avatar
0 votes
0 answers
11 views

Help with uploading file with AJAX and PHP

I have a form that I am trying to upload a file to the server with and then save the info to the database. Saving the info to the database works fine except for the file information and the file doesn'...
Darth Mikey D's user avatar
0 votes
0 answers
23 views

Help with creating commenting system using PHP, jQuery and AJAX

I am working on creating a comment system for an events plugin I am working on. I've got the main comments working fine with them saving to the database and displaying on the page. What I need help ...
Darth Mikey D's user avatar
0 votes
3 answers
40 views

Help with AJAX request

I am creating an events plugin with a commenting section for each event. I am able to save each comment, but the problem I'm having now is that I am taken to admin-ajax.php which is blank. When the ...
Darth Mikey D's user avatar
0 votes
1 answer
16 views

Update shortcode values using ajax call

I'm having a problem with a calendar, I've made a shortcode which returns events links in a grid that shows the current month view. I set $month_index in order to navigate through months (default is 0 ...
Enrico's user avatar
  • 11
0 votes
1 answer
19 views

Implement AJAX 'load more' with offset posts

I am trying to implement 'Load More' functionality via a button in a WordPress theme. We are starting by displaying the first five posts using pre_get_posts in the standard WordPress query and, when ...
Alex Ryans's user avatar
0 votes
1 answer
38 views

Xhr.send : PDF upload failed with status 400 and response 0

Hope you are doing good. I need your help if you may, please. I have a js code that actually generate a pdf client side and should supposely upload it on the wordpress server. It's not the first time ...
Louis-Emmanuel Metan's user avatar
0 votes
0 answers
20 views

Woocommerce - how can i add items to cart using onclick - multiple items at once with custom prices

I am actually creating an order form (sort of). Based on the items a customer selects, logic needs to be applied to calculate the custom price per item. Custom price is now stored in hidden input ...
Robert's user avatar
  • 1
0 votes
0 answers
14 views

How to use AJAX in wordpress front end?

I have two inputs in an HTML Widget block on a post. What I need to do: send the inputs (from the html widget) value to AJAX, construct and execute a query, render a table with the results back on the ...
ProfoundHypnotic's user avatar
0 votes
0 answers
24 views

How to make Contact Form 7 work when injected via AJAX in WordPress?

I am working on a WordPress project where I need to use Contact Form 7 as part of an AJAX response to check if certain data is available. However, I am facing an issue where the form is not working as ...
CodingWeb's user avatar
  • 101
1 vote
1 answer
24 views

changed permalink structure and now ajax functions are broken

I changed the permalinks from /%category%/%postname%/ to just /%postname%/ and now my custom ajax function returns a 500 error. The exact message I get in the console is: Failed to load resource: the ...
jon's user avatar
  • 11
0 votes
0 answers
19 views

Optimizing AJAX Query with Large Database

I have a WordPress AJAX function that performs a location-based search on a website with a large database of over 100,000 posts... The function is responsible for querying the database to find the ...
Francisco's user avatar
0 votes
0 answers
56 views

How do i set up ajax nonce

Follow the doc, I tried to set up X-WP-NONCE before ajax sent data to custom route, but it show wpApiSettings.nonce not defined. If don't set beforeSend, on the back end still can pass the nonce ...
Basco's user avatar
  • 1
0 votes
1 answer
16 views

What is the best way to ignore wordpress administration using add_filter($title) also when Ajax request

Inside a custom plugin to translate Posts contents I use add_filter() and plugins_loaded() hook to replace all $title, $excerpt, $content, $postmeta. As the documentation says wp Ajax use admin_ajax....
imagIne's user avatar
  • 41
0 votes
0 answers
24 views

WooCommerce Order Sync via Custom REST API Endpoint Failing

I have a WooCommerce website with a specialized plugin that syncs orders to a delivery company. This plugin adds a button next to each order in the orders table, which, when clicked, triggers a sync. ...
TheSwiss's user avatar
0 votes
1 answer
28 views

Does a wordpress custom plugin is fired by default on php theme ajax request?

Inside My custom wordpress plugin to translate all posts depending on get_locale() I created a php file that's add_filter() to each post content element. Ajax requests are called from functions.php ...
imagIne's user avatar
  • 41
0 votes
0 answers
22 views

how to call a non-AJAX function from within an AJAX function

I have added an AJAX function to my installation and confirmed that it works successfully. I have an AJAX function local_commit_button, and from inside that function I am trying to call a regular php ...
steve8094's user avatar
0 votes
0 answers
24 views

wp_remote_post to admin-ajax.php isn't sending body value

I'm trying to get my code to get the TMDB API data but since the API response contains multiple pages, I'm trying to recursive call my function and increment the page number each time. I'm logging to ...
SeanB's user avatar
  • 1
-1 votes
1 answer
48 views

No full page reload when navigating from page A to page B: is this possible with Wordpress?

Many websites nowadays don't reload a new page when navigating from one page to another. Instead, only the part of the page that has changed is updated (AJAX-style), but for example the menu, footer, ...
Basj's user avatar
  • 85
0 votes
0 answers
55 views

How to avoid double add to cart AJAX Add to card Woocommerce?

I have a code which lets me add to card with products AJAX on single product. The problem is that the action "add-to-card" is triggered twice and I get two notifications, two products get ...
Dariusz's user avatar
0 votes
0 answers
16 views

Can't delete reported post

I made a plugin for report posts on WordPress, the report post input was successful. but when I tried to delete the report post data on the admin page it didn't work. sorry if my english is bad. <?...
Alson's user avatar
  • 1
0 votes
0 answers
25 views

Separating HTML and PHP from the Script?

So I have this code which makes the infinite scrolling effect in WordPress. It fetches the title and read more correctly. The problem I find with this code is when I want to insert complex code that ...
RaymondM's user avatar
0 votes
0 answers
23 views

Pass form fields values from JS to PHP

I have a custom Gutenberg block plugin containing a custom HTML form. In my block I have a init.php file, where I'm enqueueing a Google Maps API library. All the frontend of the map is in jQuery. ...
TsvetkoKrastev's user avatar
0 votes
0 answers
23 views

Pass a taxonomy term slug to the code in functions.php

I need code which would load more posts into a div via WP ajax on a taxonomy term page. My code loads posts if I only specify custom post type without taxonomy term but I need it to load posts only of ...
Brgerg30879's user avatar
0 votes
0 answers
38 views

How do I change a variable in a Wordpress query with a select menu dropdown option and reload the WP query

I'm implementing a drop down menu that is populated with brand names of products. It's populated dynamically with the title(s) from a wordpress custom post type (axiss-brand). When the user selects ...
KKA's user avatar
  • 1
0 votes
0 answers
66 views

ajax select parent show child in another select and show posts in another select-ajax filter search

I'm on wordpress and I created a search filter shortcode which user can select province and show towns on another html select base on province and when user select town, in another html select it must ...
Alipvd's user avatar
  • 3
0 votes
1 answer
53 views

How could I create real-time filtering in this case?

I have a "Library" page within my website, in which there are several "templates". Each of these templates has a "Category" assigned to it. The difficulty is that I need ...
EDG_DGK's user avatar
0 votes
1 answer
148 views

Appointment booking system in WordPress

I have to make an appointment booking system with WordPress, I have a custom post type "appointments" with various various custom fields like : Name, email, date, time, office, service... ...
LesCa's user avatar
  • 21
0 votes
1 answer
174 views

Blocking admin-ajax.php from outside domain

I could not find a definitive answer on this so I figured I would ask here. I am using Elelmentor Pro forms to make a contact form, but it is getting form spam bot submissions. I have reCaptcha ...
pathfinder's user avatar
0 votes
0 answers
45 views

manipulate price of the product using AJAX

my goal is to be able to dynamically manipulate price of a product using its parameters (= inputs from the form, e.g. quantity). When the customer changes a parameter, the price will be recalculated ...
yanzi's user avatar
  • 1
0 votes
0 answers
158 views

Load more posts button and pagination at the same time

I need to have a button - load more posts - and pagination at the same time - first the button and pagination below it. I think the better way to do it is via admin-ajax.php. I can do one or the other ...
Brgerg30879's user avatar
0 votes
0 answers
47 views

I'm trying to register with AJAX

I have tried this add_action( 'wp_ajax_custome_ajax_email_check', 'custome_ajax_email_check' ); add_action('wp_ajax_nopriv_custome_ajax_email_check', 'custome_ajax_email_check'); function ...
Chandan Sayed's user avatar
0 votes
1 answer
30 views

Wordpress send Ajax where click button

I wanted to ask you, because I'm going crazy. I am adding a form to save a file by ajax, from a modal, and I don't want to reload the page after sending, just reload the modal. I have the following ...
Sergio Gonzalez Prieto's user avatar
0 votes
0 answers
42 views

wp_get_post_terms not working when using AJAX

I am trying to display terms with a load more button on the website, but I have come across a problem while the page loads first the below code works perfectly giving me 4 terms in the correct ...
mjcoder's user avatar
  • 101
0 votes
1 answer
317 views

wordpress filter for searching categories with ajax not working

I'm trying to implement a filter to show posts by categories, my elaborate code works but the filter result shows it offsite in /wp-admin/admin-ajax.php I would like the filter results to be displayed ...
EnmanuelGo's user avatar
0 votes
1 answer
133 views

contact form 7 form not working in admin panel

I am using cf7 form in wordpress admin panel: On front end its working fine but I need in admin panel. I have tried below code in functions.php but it did not work: add_filter( 'wpcf7_load_js', '...
Ravinder singh's user avatar
2 votes
1 answer
97 views

At what stage does wp_ajax hooks gets applied during Wordpress request?

At some point between muplugins_loaded and shutdown wp_ajax_*, wp_ajax_nopriv_* are executed, but where/when exactly? I have found that this is working: add_action( 'wp_ajax_actionname', '...
Miloš Đakonović's user avatar
0 votes
1 answer
59 views

How to get variable from other function inside class function using add_action for Ajax call

I want to access to variable "$sha256" from one function in other one that use both of them an add_action for Ajax call. I read that I must use a class function and add add_action with ...
imagIne's user avatar
  • 41
0 votes
0 answers
114 views

How to do a Ajax call once an order is received in WordPress WooCommerce

I want to trigger an Ajax call when I received an order. Also, I want to add that Ajax calls as a database record. Here is my code in the functions.php file. add_action('...
user2584538's user avatar
0 votes
0 answers
72 views

admin-ajax.php won't load without logging as admin- JSON Parse error: Unexpected EOF

Has anyone here run into this error before? I have a WordPress webpage and I'm trying to load a map (OpenStreetMap) with lots of markers (geojson). It works fine if I'm logged in as admin but it doesn'...
Julian Hoang Yuen's user avatar
0 votes
0 answers
33 views

add_post_meta not working within AJAX function

I'm passing some data through AJAX to a function in my functions.php, and am trying to save that as metadata to post '101' with a key name "test1". My PHP function is: function fztest(){ ...
BrassMonkey's user avatar
0 votes
1 answer
31 views

How to submit a button automatically after every scheduled hours?

How to submit a button automatically after every scheduled hours ? I tried some JavaScript but all failed. What I am doing? I am trying to fetch product categories from an external API Why I want ...
Ricky's user avatar
  • 53
0 votes
1 answer
90 views

How to add a "Load more" button for the comment section in WordPress?

I want to develop a functionality that only loads up to 5 comments per post, and if there are more than 5, it creates a “load more” button, to show 5 more comments from that post. Is there a way to ...
saibott's user avatar
0 votes
1 answer
21 views

Why are the most recent posts not appearing in a fetch request, unless I'm logged in?

A live site, using a custom theme, has recently developed an issue: recent CPTs are not being pulled through when using a JavaScript fetch request — unless I'm logged into WordPress itself. The fetch ...
verism's user avatar
  • 206
1 vote
0 answers
188 views

Ajax - how to use XMLHttpRequest in wordpress

I figured out how to successfully pass along a variable in Ajax. I can send responses and output text on the fly. However, I am having a little difficulty with passing along the Ajax data and storing ...
John Lyons's user avatar
0 votes
0 answers
271 views

How to pass javascript var to php var

I am using Ajax to pass a javascript value to php value. I am able to retrieve the data on the javascript end, but when using ajax, I cant seem to be able to transfer the data over to a php var. I get:...
John Lyons's user avatar
0 votes
0 answers
76 views

Ajax infinite scroll random order shows duplicate posts on custom post type

I have a custom post type which I want to show in a random order and with loading more posts with ajax infinite scroll. The problem is that I get duplicated posts on page two and onwards. I do ...
Lisa's user avatar
  • 3

1
2 3 4 5
54