We should be able to fix the query by doing this instead:
$query = new \WP_Query([
'post_type' => 'location-data',
'posts_per_page' => 1,
'post_status' => 'publish',
'title' => $title
]);
This is because page is unnecessary and may not be the parameter you actually needed, paged would have been more appropriate, but it too is unnecessary.
Most importantly though, post_title is not a parameter of WP_Query according to the docs, instead it lists title. post_title is only mentioned as a parameter for search columns.
Related Posts:
- Meta Query doesn’t works as espected
- Multi line of $wpdb->query just run 1 time and end the loop right after
- Meta key in wp_query bug?
- Should I use Pre Get Posts or WP_Query
- Is it necessary to use wp_reset_query() in a WP_Query call?
- Post_count only shows the number of results per page
- WordPress retrieving meta data for all custom post types in list view
- how to show posts that are missing a meta_value
- What is “main query”? [duplicate]
- WP_Query: query posts by ids from array?
- pre_get_posts with get_posts
- Is it true $wpdb->get_results is faster than WP_Query in most cases?
- Why does pagination always break when used on any form of a home page?
- Changing a theme’s search function to only show results from woocommerce?
- Multiple orderby parameters in pre_get_posts() action
- Select posts wich has no relationship in custom taxonomy
- Finding the next 5 posts
- How to wp_query posts with ajax
- post thumb nail
- Filter by title content and meta key at the same time
- Get all remaining posts after a particular post id
- wp_query with multiple custom fields
- Removing posts from the returned wp_query. Cannot use object of type WP_Query as array
- So strange result of wp_query and have_posts
- Minimising number of queries on a page when using Advanced Custom Fields
- What is considered a default query for the request filter?
- $wpdb insert is not work
- How to find exact match for search term in WP_Query? What is the additional string added in LIKE query in WP_Query?
- Improve wp query perfomance on large db
- If two first numbers exist in wp_meta_query value
- How to get the WC_Product Object when using a WP_Query in WooCommerce
- Two different conditions with a single WP_Query
- How to query for posts without a post_format
- get_posts – find out if querystring was crap and fallback is used
- Custom Search Result Page displaying only 1 result.
- Function get_queried_object() return NULL in custom taxonomy
- Search pages that are a child of the current page
- Change query_posts to WP_Query in page but does not work
- The pagination on index.php doesn’t work on a first page
- Include tags in WP_Query
- Modify WP Query post__in before have_posts()
- WordPress search posts by author name with autocomplete
- WordPress multisite – fallback on subsites to main site on 404 and dealing with switch_to_blog function
- WP Query using tax_query & meta_query
- How to control a common terms list from one place?
- Exclude Category filter from Portfolio section
- Search form not working with custom query?
- How to increase load time of an archive/search page (WP_Query)
- empty WP_Query object on local install
- Prevent author bio page from showing in search results
- Changing the default wp_search_stopwords
- Query posts only without featured image
- WP_Query array key / value pairs?
- Get posts from multiple tax terms
- How to use WP_Query() on single.php?
- Tax Query only returns for the first of several terms
- Can’t fetch Custom Post Type Data through Custom Query
- Loop increase in while loop not working
- Appending to existing WP_Query’s meta_query if exists
- WP_Query offset is returning post from prevois loop
- Tax query is not working!
- How To Keep Search Title the same on paged Results
- Get next/prev image/attachment in time with date query
- Filter out a meta key in the Search results page with two CPT
- Reordering content using a meta value
- How to add a recent post function to a text widget I created for practice?
- Can I make a search query which includes a space?
- Help with if statement inside while loop
- Optimising WP_Query with ACF Fields
- WP_Query – display posts by custom field and order by another
- WP_Query no result if keyword contains number
- WP_QUERY order posts by two combined meta_value dates
- Order by value of Custom Field using url string
- update_post_meta performance in a loop woocommerce
- How to set meta_query if get_post_meta returns nested array for that key? [duplicate]
- Is the ‘parse_query’ filter still valid to change filtered content on admin list view?
- query_posts() doesn’t seem to be called in my page
- WP_Query returns empty if meta_query has more than 7 values
- query.php – multiple is_category functions
- Custom query with post_class filter using current_post not working
- How to get several fields from wp_query?
- Overwriting auto-appended NOT IN query in WP_Query
- posts_per_page not returning correct number of posts
- WP Query posts__in not working with array
- query_posts with sorting on a custom datestamp
- Conditionals in WP_Query
- Why WP_Query in functions.php is not working when get_posts works?
- Next / previous posts link doesn’t show up with Posts 2 Posts
- Loop the posts between two dates selected using jquery datepicker
- Query Posts by date range with fixed beginning and end
- query by meta value then date and not empty meta value
- Issue with sorting by post date and custom post type
- Is it possible to use WP Query to orderby custom meta value and custom taxonomy?
- Display all custom meta field values from the database using ACF Repeater
- Can’t get LIKE to work with wp_query [closed]
- WP Query returning all posts when Meta_query is null
- Inherit args from the main wp_query or wp_comment_query to my custom query
- Filter on one post type with taxonimy and get other post type
- Get related posts from tag otherwise from category (Ajax Load More plugin)
- WP_Query equivalent of SQL UNION ALL