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:
- username_exists() function can’t be access without logging in
- WordPress AJAX Pagination with query_posts
- How build a custom login/register form with error handling?
- Do I require the use of nonce?
- 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
- Security – Ajax and Nonce use [closed]
- Validate a users email address when using gmail to register
- Use ajax to update_post_meta
- Problem with WordPress Ajax form
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- How to set a custom path, for ajax image upload folder in admin?
- admin-ajax.php responding with 0
- Can I use HTTP POSTs? Is there a better alternative?
- How to make custom total price reactive in navigation
- How to prevent those PHP variables from being cached on WordPress?
- Use ajax from function.php
- get post based on category chosen in drop down – The ajax method
- get current custom post ID by WP_Query method
- Create onClick Event to Re-load a Widget
- Creating a Multi-Level Associative Object Using AJAX
- How to store data from multiple forms using ajax and php
- Ajax loaded form replaces form action with Ajax url
- prevent default not stopping page refresh. Passing form information to and from php with ajax in a wordpress site
- Gutenberg block – Save PHP function’s output as HTML?
- Image upload via FormData API and AJAX is not working ($_FILES always empty)
- Ajax date_query not working past the first iteration
- Why ajax doesn’t work on certain wordpress hooks and reload the page instead?
- Posting and image insertion problems after EasyApache4 and PHP 7 upgrade
- How to add a do_action on refreshing of WP customizer?
- [jQuery]Adding shortcode
- Display parent and child taxonomies in separate drop down select fields
- how to update and display an option without reloading the page
- WordPress admin-ajax.php 400 bad request
- Problem with AJAX in wordpress plugin
- How to keep track of when a vote is cast?
- set post limit at load more ajax wordpress
- AJAX wp_insert_user WORKS but responds with “The site is not enabled”
- Ajax filter button display all posts
- Compare $_POST returned values with term array
- WordPress REST API register_rest_route give a 500 error
- How to use AJAX to call php page with parameter
- admin-ajax GET response bad request
- javascript variable to wordpress php variable
- Post not populating for custom post type based on category selection
- Output votes to div dynamically in wordpress
- Incrementing PHP variable onclick to display posts by month
- Proper way to use WordPress function with AJAX PHP file
- How to use AJAX in WordPress in MYSQL query?
- Live search from database table
- Processing ajax call to php to insert into mysql database
- Ajax URLs without #!, how to prevent falling into single.php on load or reload?
- Search Ajax Call – Use Form Data in Response
- Why does PHP called with Jquery AJAX not allow additional php code to be added?
- Display WordPress search results based on the selected Sub-Category
- Deleting records with AJAX, deleting records as I search
- Using some Loop or repeatable fucntion in AJAX and PHP to reduce repeatability
- Database entry removed on browser refresh, Ajax PHP jQuery
- How do I call a value from the datase using ajax
- Post form – AJAX won’t upload featured image – Plugin development
- Load more posts using AJAX based on posts inside WP_Query
- PHP calling AJAX function that relies on passed PHP function values not working
- Where to add my PHP codes for AJAX Jquery to work?
- Adding ELSE argument to AJAX Live Search for “No results found”
- How can i find wrong word in search box and replace with correct word
- How to use wp_ajax_set_post_thumbnail?
- ajax contact form not submit message
- Can an AJAX callback function access a PHP variable which was defined during initial page load?
- Can’t make lazy load for my site, help!
- How to reload a php script, using AJAX and jQuery
- Change WooCommerce currency programmatically on AJAX request
- use with class file into wp_ajax hook
- Why the responseText containing those two arrow signs at the beginning
- WordPress Ajax filter: Create two loops for different output styles?
- Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
- Following/Followers Users list Using Ajax Pagination inside Author Profile
- How to call a function from functions.php with ajax?
- Custom theme admin-ajax.php 400 (Bad Request)
- Ajax in a class instantiated via shortcode
- number of posts with “Load More”
- How to send Ajax Call from frontend without using wp_localize_script in Theme
- Include search tags and users in my search results system
- Problem with ajax request and directory structure after site migration
- Apply filters when loading post via ajax
- ajax form with multiple submit buttons and values
- Registration form not registering First and Last name
- Result from wp_send_json adds line feed
- Modify php code to pass a page id as a parameter in order to create a breadcrumb
- WordPress will suddenly stop saving files uploaded by my code (ran in nopriv ajax)
- AJAX with Selectbox Plugins (Select2, Chosen, Selectize)
- ajax form function error
- Ajax Load More or View More functionality for woocommerce category layout by template overriding
- Load Meta box value into div AJAX [duplicate]
- Detecting IP Address of someone using ‘copy’ function [closed]
- 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
- AJAX returning blank result
- using AJAX [object Object]
- Ajax – how to use XMLHttpRequest in wordpress