There is no such thing as an AJAX call that’s inside the loop. The server has no idea what page or where on that page an ajax call is coming from unless you explicitly send it that data as a part of the ajax call. You’re going to need to send some data to the php function so it can recreate the correct query (or the current post if that’s all you need.) i.e. You send a post ID in the ajax, the php function it calls then does $post_id = $_POST[post_id];
(please add your own sanitization and validation here.) Then instead of calling the_title()
you would call get_the_title($post_id)
Related Posts:
- Pass form attributes to another php template in wordpress
- Problem with ajax request and directory structure after site migration
- Find the method which AJAX GET calls
- A javascript function that simply runs a php function on the plugin
- Custom HTML form using PHP – help with ajax/username validation
- AJAX Filter WHILE Loop not working WordPress
- Code works on page-example.php by not category-example.php
- Ajax not updating to database
- WordPress 404 when using AJAX to call php function
- Retrieve $_POST data to send to javascript without using localize script
- wordpress ajax pagination
- AJAX Returning Way Too Many Posts
- WordPress AJAX load post metadata in modal
- how use php query in AJAX jquery
- Ajax Load more CPT via shortcode
- Apply filters when loading post via ajax
- Why I’m Not Having Access to “$_POST” Data Outside My AJAX Callback?
- wordpress ajax return 0
- Submitting my form to the database and then redirecting to payment site
- MySQL query in WordPress with AJAX
- Ajax call URL 404’ing when pushed to staging server
- wp_delete_comment is doing nothing
- Modify category archive page loop on functions.php
- Run insert if no entry otherwise run update with ajax
- Pass the updated value of aid from form using ajax
- ajax form with multiple submit buttons and values
- Registration form not registering First and Last name
- 403 (Forbidden) delete file image in themer folder
- Result from wp_send_json adds line feed
- How to run ajax in WordPress Post?
- 500 (Internal Server Error) of external php file
- Use jQuery and AJAX to get HTML
- Is custom behaviour possible when asynchronously uploading?
- Modify php code to pass a page id as a parameter in order to create a breadcrumb
- Adding instant search to wordpress page
- Problems with plugin that fetches data from database with ajax
- Add php function into .js file (for tinyMCE button)
- WordPress will suddenly stop saving files uploaded by my code (ran in nopriv ajax)
- AJAX with Selectbox Plugins (Select2, Chosen, Selectize)
- Dynamic Gallery
- Execute PHP code in Javascript onclick
- best way to communicate between php and jquery/javascript
- Loading a post’s content, into a div outside the loop, when it’s title is selected in a list
- Fatal error: Uncaught Error: Call to undefined function wp_nav_menu()
- WP_Query based on another query on the page
- Data inserted in database, but ajax calls error function
- AJAX & PHP | Call a specific PHP function from a PHP file via AJAX?
- Load php function with AJAX on modal window
- ajax form function error
- Ajax Load More or View More functionality for woocommerce category layout by template overriding
- Cookie not created in AJAX request
- AJAX: WordPress filters inside $html do not work as intended
- Why not showing all post by default in my jquery filter
- Load Meta box value into div AJAX [duplicate]
- send meta box input data without publish button
- Jquery autosave text area after typing
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- Detecting IP Address of someone using ‘copy’ function [closed]
- wp_enqueue_scripts with JS script as a string
- notify users when changed database
- Correct way to perform a GET to another PHP file hosted on wordpress
- How to display inputted data in Ajax without button or click event
- WordPress Query -> Ajax Query
- how to display tables via ajax
- How to use url and amin-ajax.php
- WP – Ajax call back data printed in the console.log
- How to Set Page Pagination Using Ajax JQuery – WordPress
- How to pass and validate nonce in custom REST routes
- Remove Woocommerce product from cart with ajax/fetch
- Save Edit button then disabled readonly metabox
- getJSON response to PHP
- ajax problems on loading page [closed]
- Woocommerce – Include custom user meta in order ‘filter by registered customer’ Ajax search
- WooCommerce Modal Fly cart on add to cart – With AJAX
- AJAX returning blank result
- AJAX WP_Query’s order and orderby parameters not working
- How can I use AJAX in child theme template?
- Word press – JSPDF – Sending PDF as attachment from wp_mail – Special characters
- Upload multiple files via ajax from an HTML file input
- using AJAX [object Object]
- How to pass javascript var to php var
- Ajax infinite scroll random order shows duplicate posts on custom post type
- Ajax – how to use XMLHttpRequest in wordpress
- Help with AJAX request
- I got this error POST https://localhost/meraboilerwp/[object%20Object] 404 (Not Found)
- How can I display a Divi content inside a modal based on an AJAX request
- Start a long running PHP process via JS/Ajax and monitor progress on admin page
- Display posts based on the selected category when no subcategory is chosen
- custom AJAX filtering logic and outputting results into an Elementor Loop Grid widget
- How to make this shortcode not refresh the whole page when i use it on frontend
- Session seems to break
- Data insertion after clicking a button does not work (script, AJAX, PHP)
- WordPress Insert line in DB when clicking a button
- Help with uploading file with AJAX and PHP
- Help with creating commenting system using PHP, jQuery and AJAX
- Update shortcode values using ajax call
- Woocommerce – how can i add items to cart using onclick – multiple items at once with custom prices
- ajax select parent show child in another select and show posts in another select-ajax filter search
- WooCommerce Mini-Cart Problem
- Trying to GET data with ajax from database and show in fullcalendar