Your inner loop overwrites the contents of $post
, so any later template tags use the values of whatever it last contained.
“But I used wp_reset_postdata()
!” you say? What that function does is try to restore $post
from $wp_query->post
. It’s meant to restore the main query after secondary queries. You have two secondary queries here, so that method fails.
To fix it- either use $wp_query
as a new WP_Query
instance for your outer loop, which will result in wp_reset_postdata()
working as expected, or assign your outer post to some other variable name and don’t use template tags that rely on the global $post
.
Related Posts:
- get_posts empty when called via Ajax
- WordPress function to get term or post object by id
- WordPress ajax get content post id
- AJAX – get_posts for a specific post type returns empty
- Portfolio list view after clicking back button
- (Frontend AJAX) get post data WITH image thumbnail?
- How to get data with Select AJAX PHP
- ASP.NET MVC controller actions that return JSON or partial html
- How to check if I am in admin-ajax.php?
- Ajax in a settings page (update_option is undefined)
- gettext does not translate when called in ajax
- Execute one AJAX request after another AJAX request finished
- admin-ajax.php vs Custom Page Template for Ajax Requests
- Load tinyMCE / wp_editor() via AJAX [duplicate]
- Is there a hook that fires before an ajax call?
- AJAX request from Chrome Extension to WordPress Website
- How to correctly load wordpress in a non WP script for AJAX request
- Why is admin ajax reloading my page
- Plupload in metabox – AJAX action not working in Class
- Why this plugin doesn’t work with media upload page?
- CPU usage: AJAX and Heartbeat API on admin pages
- Solve cors problem using rest api or ajax
- Can part of my WordPress website be headless?
- Nonces, AJAX, script variables & security in WordPress
- Extending wp JavaScript base class to make a post request to a custom REST endpoint
- Why would admin-ajax.php redirect to the home page for logged out users?
- wp_localize_script escaping my url – fix or alternative
- Admin Ajax and HTML5 Formdata
- Implementing an AJAX POST API call in wordpress
- WordPress ajax problem need wordpress expert?
- Identical wp_rest nonce returned from rest_api
- Ajax WordPress Login needs to be stayed in current page Url without redirecting
- wp_ajax function did not call
- Can’t get result from sql using ajax result
- Theme Customizer – Conditional Controls
- Edit a different page in WP Customizer
- Caching-Plugins and Ajax-Page-Parts
- Ajax loading duplicate post
- WordPress AJAX – how to return true or false in the callback function
- get post attachment using ajax
- WordPress Ajax POST Error 403 admin-ajax.php
- How do I detect in which page ajax_query_attachments_args is loaded?
- Ajax post returning full html page as response
- Which allowed API hooks work to add wp_ajax action?
- Pass additional parameter with async upload
- Ajax store response json in variables
- Performance optimization of tree like structure
- WordPress search results with Ajax, get_post_type() not working
- How can I set cookies on both secure and non-secure origins at the same time?
- Variable Products Being Added to Cart with AJAX on Shop and Category Pages
- Audio TAG Not using MediaElement When Page is loaded through ajax
- Is it secure to use admin-ajax.php in front?
- Best way to use ajax front-end?
- Ajax calls from the theme directory
- How to pass parameters from jQuery ajax into PHP function?
- How to add ajax url to js using wp_add_inline_script()?
- merge wp rest api query to get posts per category does not work
- use jQuery.load() to include a php file in a div, wp_query() is part of php file
- Load more posts in the same category – Ajax + Timber
- Redirect after saving form; and yet use wp_die()
- ajaxt returning object object [closed]
- Load more posts (Ajax) in tabbed sidebar on single.php
- Something strange with ajax
- admin-ajax.php returns 0 even when the post status code is 200 OK
- Why is the file not uploading to the server?
- Get localize of a loaded javascript
- is there’s a way to get the next page content generated by page break block with ajax call?
- Merge PDF files from post custom fields(ACF) into one PDF file and respond back the created PDF file, WordPress(AJAX Request)
- REST public POST giving 403 forbidden nginx
- Query data after an Ajax insert
- Sending email through Ajax without page refresh hangs on admin_ajax.php
- Is there a public ajax endpoint?
- Why Ajax Doesn’t Work?
- How can i do public ajax call?
- How to prevent multiple post with same meta value being created simultaneously in WordPress (with ajax)
- Content including hooks inside wp-settings.php are being called twice in WordPress
- Problem when sending file via ajax
- wp_verify_nonce not working on the mobile device
- Can’t GET Variable from AJAX URL
- JS global variable doesn’t update
- 404 error custom post type rest api
- How to update cart total after AJAX success
- Change button text after ajax db update
- How to implement AJAX within a class storing shortcode atts as class variables
- Jquery wrap permalink in a data-attribute?
- Load .php file into div using ajax
- how to avoid reloading/refresh the page when displaying the post of wp_list_categories
- Native WordPress Video Shortcode Not Working After Post is Loaded via Ajax
- AJAX Post from same domain to a wordpress page
- Add Ajax loaded posts to existing posts
- Using AJAX for dynamic settings pages
- Speeding up admin-ajax.php
- admin ajax is not working for non logged in users
- AJAX admin Internal 500 error Failed to Upload
- Class property not visible inside ajax callback function?
- Bad Request 400… jQuery ajax post of json data to wordpress admin-ajax.php
- Why are the most recent posts not appearing in a fetch request, unless I’m logged in?
- Successful ajax call returns lots of whitespace and text of code with 0
- How to submit a button automatically after every scheduled hours?
- At what stage does wp_ajax hooks gets applied during WordPress request?