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?
- Use REGEXP in WP_Query meta_query key
- Why is the loop not empty on some 404s?
- Multiple custom fields for ‘orderby’ in ‘WP_Query’
- How to order by post_status?
- How to paginate wordpress [gallery] shortcode?
- switch_to_blog() performance considerations & alternatives
- wp_query->max_num_pages always returns 0 on custom post type
- get_template_part in for loop
- Display recent posts from the same category as current post in sidebar
- Load more AJAX on WP Query
- Using is_main_query to select custom post type on certain page
- WP_Query ordered by custom field that is a date string?
- How to count post type that has a particular term?
- Group posts by meta_key
- How to Get All Posts but the Private ones?
- How can I hide posts that are over 2 years old
- WordPress custom search form with pre_get_posts not work
- order by multiple meta keys in pre_get_posts
- Order By Multiple Meta Fields
- WordPress: Keep order of query_posts list of post ID’s using post__in
- Best practice custom function, where to echo the variables?
- How to get user_id from wordpress database inside ajax function?
- How to combine meta_query and post__in in WP_Query
- query user display_name failed in a custom mysql query foreach
- Query with custom taxonomy not working
- Query posts by specific word on title
- Date and Category query with filter
- Get posts for which a custom field is not present, with get_posts
- How to change main query based on post meta
- add active class based on permalink and url
- Loop Split two Columns
- Search by post id in a specific page then auto-redirect to searched post
- Pretty urls for custom pagination
- WP_Query with ‘rand’, but equal number of posts from the taxonomy terms given
- WP Group posts by year(desc) > month(desc) > date(asc)
- Adding a tax_query to a WP_Query Object
- Check the Specific Meta Key IF its Meta Value is Empty then… (WP Post Meta Query)
- wp_query search not taking keywords with together for multiple words
- Adding a html class based on post count
- How I can change the condition or compare operator for WP_Query in pre_get_posts
- Filtering posts by archive showing all years
- Apply filters to main query instead of creating new one?
- WP_Query returns different results from get_posts() [closed]
- WP_Query posts_per_page strange caching
- wp_query show all values
- Why having more than 10 clauses in WP_Query results in some outputs being dropped?
- mysql query order by
- Why do I have to use pre_get_posts with custom WP_Query to reset posts_per_page?
- WordPress dynamic AJAX query
- Custom Taxonomy Breaks Pages
- Using rewind_posts for displaying multiple categories
- Query to get last posts from authors of blog
- WP_QUERY tax_query not working
- How to get latest post excerpt from a specific category?
- Get all content on a “single page” site depending on language
- Get list of all Grandchild Pages
- get latest added term from taxonomy and insert into php variable
- WP_Query not returning correct result with meta_query parameter
- How to do WP_User_Query for Nested Array value Inside Nested Array field
- Custom query to retrieve oldest post and retrieve others with date interval
- Custom order revolution sliders post base slides as inserted in Specific Posts List field
- How to display Woocommerce products list by tag
- Display the search results like the original pages
- Pagination on archive.php not working?
- Unable to reset post data in wordpress custom query
- Check the product in the cart from which category is and show message
- How to filter on placeholder image
- Slow wp_posts and wp_postmeta query using Advance Custom Fields
- WP query for two post types how to order newest to oldest with two different meta fields?
- Get posts with any value in attribute
- WP_Query & shortcode : Return 3 articles from a category WordPress
- Order & Orderby clause not working with custom query
- WP_Query doesn’t works inside loop
- Pagination in WP_Query?
- 2 Loops on one page – pagination of 2nd loop ignore array of excluded posts
- WP_Query with child element
- Custom query to order by multiple taxonomies
- How to add archives (with pagination) to page template?
- Custom WP_Query with SQL directives for getting posts by authors and terms
- No content found on page 2 of pagination with 1 post per page
- shortcode using multiple WP_Query’s with multiple category names not fully functional
- Different sql queries count indicator on the main page [closed]
- Query Posts to fetch Posts with Unique Tag
- Shortcode does not display pagination [duplicate]
- Paginate wp_query while utilizing post__not_in
- Get next post when using pagination with WP_Query?
- Can’t figure out query logic
- Convert a WP Query into a simpler SQL query to fetch only COUNT of posts
- orderby and order filter in get_posts or WP_query function in wordpress not working
- How to order “top rated” results by date and meta key?
- Getting posts via WP Query
- Search query alteration not working for meta values
- I’m trying to get posts under a custom taxonomy but I don’t know what I’m doing wrong here
- WP_query shortcode inside acf Repeater breaks the repeater loop
- Multiple queries and pagination
- How to short circuit a wordpress query that is not related to posts?
- order meta_value_num not working