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:
- How can I fetch loop of post titles via AJAX?
- How build a custom login/register form with error handling?
- Is having multiple theme customizers for different pages possible?
- Where to include php files in wordpress and how to refer to them later [closed]
- Admin Media grid view images won’t load
- Passing JSON data from WP Query into AJAX causing NULL errors
- AJAX / Read More: multiple check_ajax_referer() and wp_create_nonce() not working independentely
- Handling an Ajax form submit
- Ajax call to my WordPress website from an external application [duplicate]
- Validate a users email address when using gmail to register
- Custom WordPress+PHP+MYSQL+AJAX form, submit event not captured by Javascript, but does POST data to the DB
- Use ajax to update_post_meta
- WooCommerce: update custom fields after checkout validation failure
- How to speed up admin-ajax.php in wordpress
- Can I use HTTP POSTs? Is there a better alternative?
- How to make custom total price reactive in navigation
- How to test nonce with AJAX – Plugin development
- get current custom post ID by WP_Query method
- Ajax not working es expected (Returns 0)
- Creating a Multi-Level Associative Object Using AJAX
- Ajax category filtering products default show all
- Status 400 for AJAX POST Request with admin-ajax.php
- Why ajax doesn’t work on certain wordpress hooks and reload the page instead?
- Why ajax doesn’t work on certain wordpress hooks?
- AJAX pagination, update current page
- adjust section according to country?
- Posting and image insertion problems after EasyApache4 and PHP 7 upgrade
- Ajax call return 404
- How to add a do_action on refreshing of WP customizer?
- How to disable controls in theme customizer?
- AJAX button action in foreach
- Unset session variable on page reload / setup but exclude AJAX
- WordPress ajax-action failing because of newline in response
- Making an AJAX call to refresh a table
- load ajax using admin-ajax.php
- Ajax button not working
- Simple AJAX notification when the new post is added to the database
- Is it possible to create new user from external form using REST API?
- When echo follow Ajax button inside Ajax pagination template not working?
- jQuery Ajax PHP function call returning [object Object]
- Calling PHP Scripts in Ajax that are in PHP Snippets
- Retrieve Json data and create multiple pages with it
- Loading Posts & Category with Ajax
- PHP Warning: Missing argument 2
- Allow user to Upload image and manipulate it on the frontend
- How to SELECT number from table and use in calculation . Unsupported operand types
- Execute Jquery when a specific page in my plugin is loading
- what does $options = get_option(‘test_theme’); do?
- How to load previous or next attachment with jquery ?
- Validating an email input from form field before submit using JQuery, AJAX, and PHP
- custom add note meta box with add button in wordpress
- Disclaimer that will show every refresh of the page
- Ajax on the Administration Side of plugin – wp_localize_script – how to pass value from JQuery to PHP function in class?
- How do I make these combination select filters work when only one dropdown is set? They work in WordPress 5.8.2 but don’t in 5.8.3
- duplicate posts with ajax load more wordpress
- Failed to load resource: the server responded with a status of 500 (Internal Server Error) through wp_admin_ajax.php
- My Custom Post Type AJAX Query is Returning no posts – why?
- Change ajax live search results
- Ajax filter with loadmore button
- Update $wpdb query with AJAX
- AJAX and custom pages
- $.ajax results in 403 forbidden
- AJAX to add to cart multiple products woocommerce
- wp_set_object_terms returns 500 error when called through AJAX function
- How can i send id of the currently posted form data through json response in custom wordpress plugin?
- Cannot successfully execute AJAX script to call function.php specific function. Using XAMPP localhost to test
- autocomplete in wordpress using ajax with json-data
- Contactform7: display results from CURL
- ajax polling with admin-ajax.php
- Remove item from post_meta array via AJAX
- wp_send_json erase last value
- defined (‘ABSPATH’) false after AJAX post to other PHP-file
- How to load WP_Editor JS files manually (with AJAX)?
- A javascript function that simply runs a php function on the plugin
- WordPress 404 when using AJAX to call php function
- wordpress ajax pagination
- how use php query in AJAX jquery
- wp_delete_comment is doing nothing
- 403 (Forbidden) delete file image in themer folder
- 500 (Internal Server Error) of external php file
- Use jQuery and AJAX to get HTML
- Problems with plugin that fetches data from database with ajax
- 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
- AJAX: WordPress filters inside $html do not work as intended
- Jquery autosave text area after typing
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- Correct way to perform a GET to another PHP file hosted on wordpress
- How to use url and amin-ajax.php
- WP – Ajax call back data printed in the console.log
- AJAX returning blank result
- using AJAX [object Object]
- 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
- Session seems to break
- Trying to GET data with ajax from database and show in fullcalendar