I believe Milo is right, it’s probably a filter affecting this. Ajax requests look like admin requests (that is, is_admin()
returns true), so it’s possible that something is checking if is_admin()
and adding the filter in those cases.
You can set 'suppress_filters' => true
in your args array and it will probably work. Note that doing so can prevent a query from being cached, or prevent plugins from doing what they need to with a query. It’s possible that this may not affect you, but still something to keep in mind.
Related Posts:
- Order & Orderby clause not working with custom query
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- WP_Query orderby date not working
- Order by DESC, ASC in custom WP_Query
- Secondary Sort (fallback) for WP_Query
- Query Posts in a Predefined Order
- wp_query->max_num_pages always returns 0 on custom post type
- ajax category filter
- How do I order pages and categories by ID or name in the same query?
- Load more AJAX on WP Query
- WP_Query ordered by custom field that is a date string?
- How to pass custom parameter to WP_Query for filtering in pre_get_posts
- WooCommerce: filter by parent product’s taxonomy and product variation’s meta data
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- ‘posts_where’ filter not applying ‘WP_Query’ in `wp_ajax`
- Order posts ascending with number in title
- List taxonomy terms plus their latest post ordered by post date
- Using AJAX to return search form results
- Foreach-generated custom tax queries, each with an ajax “Load more” button
- WP_Query order by date in meta_value
- How to use order RAND() on WordPress?
- Show all parents and children in custom post type in right order
- Order WP Query posts by custom order calculated from post meta values
- How to get user_id from wordpress database inside ajax function?
- Update Loop with Form
- Meta query with order by another custom field
- Refine/Filter WP_Query Posts with jQuery or Ajax
- How can I pick a single post from the latest 3?
- Wp query orderby ‘title’ doesn’t work
- Show selected images on top in Media Manager
- How can I order Wp_Query hierarchically?
- How do I sort posts with multiple pages
- WP_Query ajax loader detect end of posts
- Order WP_Query by multiple fields, subtracting them from one another
- Ajax Pagination on Ajax filter
- Wp_query returning only one post while query through ajax
- SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)
- Order By table field comment_status in WordPress > 4.0
- Complex WP_Query order request: DESC by day, but then ASC by time
- WP_Query orderby author__in
- How to orderby multiple meta fields if some fields are empty
- Sort wordpress custom posts based on meta value
- Ajax WP_Query reutrns no results on author.php
- Order ascending is ignored in meta query?
- How to filter a query by multiple meta keys and order by other meta keys
- Multiple Orderby’s using random order WP_Query
- Ajax future single post query doesn’t work when NOT logged in
- Debugging wp_query orderby for taxonomy
- WP Query – order posts by meta field first and then order the rest
- Advanced WP_Query with meta_query, orderby?
- How to Order a list of taxonomies? orderby?
- Order is breaking wp_query
- How to use a dropdown to filter posts by custom field
- Retrieve data from wordpress db via input and put those result in dropdown
- WP_Query with multiple orderby NOT working with ASC and DESC, what’s wrong?
- Filtering by multiple conditions in the loop
- WP_query is not returning the expected result
- Orderby two meta fields not working
- I need to run a AJAX Fuction from within a WP_Query but only works on first item
- Randomly select one of last 3 posts
- Change post query onclick
- how to retrieve WP_Query without ordering by date [duplicate]
- How to filter a static post page with ajax and $wp_query
- orderby ignored by wp_query
- WP_Query orderby
- What’s wrong with this meta query? (order by meta key, then title, doesn’t work)
- Using Ajax and WP_Query to load more posts on category page fails
- How can I order a post query’s results based on the number of matching taxonomy terms?
- How to sort store location by specific category order in WP store locations
- Custom order of posts in wp_query and different taxonomies
- WP_Query random ordering not working since 5.4
- WordPress Query custom ordering by temporary variable
- Filter admin ajax data by url query
- Order by meta date with a thousanth of a second defaults to post order
- Load WP Query with Ajax
- How to get_comments() ordered by date and parent?
- WP Query. Ordering posts by another post types meta
- Best way to query posts and order by relevancy to query
- Is instantiating WP_Query not possible within an admin Ajax call?
- wp_query sorting – one specific meta_key value at last and then sort by create date
- WordPress conflict with multiple load more posts functions on click
- Show All with Isotope
- Search Filter With Custom Taxonomy and Custom Fields : How do I handle it via plugin?
- query_posts based on a meta_key
- Display three sequential posts on each page load, without repeating previous
- how to avoid reloading/refresh the page when displaying the post of wp_list_categories
- Order posts by more than one variable (meta_key and publish date AND time)
- Create custom order sortby based on array of id
- Sort by meta key within same day
- Find by post_meta, then sort by post_meta, then sort by date (wp_posts)
- WP_Query for liked posts is showing all posts if none are liked
- Declare inline background image in functions.php
- Order Custom Field by Price
- Show sticky post before other WP_Query
- Fire query on ajax post url page
- Order by multiple meta keys on wordpress
- How return normal search result using wp_ajax action for wordpress
- WP_Query with several meta_query-statements and order by meta_value
- AJAX search function resets wp_query vars
- WordPress Ajax search filter on dropdown select