how to write a WP_Query that returns the custom field data
This is not typically necessary. You can simply access meta data for each post in query individually (as you do already). You can also iterate through query more than once in a page (it rewinds to start automatically, that’s what while( have_posts() )
part does).
If you are concerned performance aspect — meta data access is heavily cached in memory (or object cache). Retrieving meta data multiple times in page load will not cause duplicate queries, it will only be fetched once and reused.
Related Posts:
- Loading two different AJAX requests on two different pages
- WordPress live search and filter
- Nested JSON objects – do I have to use arrays for everything?
- Uncaught TypeError: Cannot read property ‘length’ of undefined
- Failed to load resource: net::ERR_FILE_NOT_FOUND loading json.js
- jQuery AJAX cross domain
- Loading local JSON file
- Uncaught TypeError: data.push is not a function
- How to convert selected HTML to Json?
- SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
- SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
- How to display raw JSON data on a HTML page
- Convert array to JSON
- How to filter JSON Data in JavaScript or jQuery?
- Javascript : array.length returns undefined
- How to add a button dynamically using jquery
- Complex JSON nesting of objects and arrays
- Uncaught SyntaxError: Unexpected token with JSON.parse
- How can JavaScript save to a local file?
- Defining a HTML template to append using JQuery
- Can’t get a JSON object in response to an Ajax request with wp_ajax
- WP_Query result in form of Rest API results
- IP address character limit
- WP Rest API v2 return posts with specific tag
- JSON: schedule creation of json file
- Load more AJAX on WP Query
- Using AJAX to return search form results
- Foreach-generated custom tax queries, each with an ajax “Load more” button
- How to Use JSON With AJAX?
- Why use JSON API to display recent posts?
- How to capture a variable query string, then append it to all URLs in a WordPress site
- Update Loop with Form
- Refine/Filter WP_Query Posts with jQuery or Ajax
- JSON output returns page source code [closed]
- Querying A Post That Includes Two Taxonomies Using JSON Rest API
- How to use wp_query to post count by search term > group post count by date > convert to json. (ex. result 12-21-2020 – 343)
- Load More Posts Button – AJAX
- Ajaxify This Code
- I want to import my Json file into a custom made display-modal. How do i link my Json file?
- Loop Performance > JSON files vs. WP_Query vs. REST API
- Filter wordpress post categories with jquery/ajax and pagination?
- how update data through ajax and jquery
- JSON – Create rest api endpoint for Advanced Custom Fields
- Change AJAX filter from POST to GET for URL Parameters
- How to get more data of a post by wp_query
- Parse wordpress blog data using json api and ajax
- Ajax (jquery) wp_query pagination returns -1
- WordPress AJAX Request returns 400
- How to get a specific string from a url
- Change normal grids to masonry grids
- WordPress live search and filter custom fields
- Remove escape characters from JSON string pulled from a database
- Slick slider for post doesn’t display anything
- Filter admin ajax data by url query
- Finding post ID dynamically on click
- How to use jQuery validation to set the search bar to accept only a specific input?
- WP query retrieve the src of attached image
- WordPress conflict with multiple load more posts functions on click
- 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
- How to solve this script problem in theme directory?
- Sorting Posts Based On Meta Value Using AJAX
- Loop the posts between two dates selected using jquery datepicker
- Custom search: Search posts but display parent page in results
- Stylesheet won’t load even when linked
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- JSON Object Value Show Undefine
- AJAX search function resets wp_query vars
- WordPress Ajax search filter on dropdown select
- Custom Taxonomy in custom REST API search
- Simple Apex Charts with jQuery not working
- How to read an external local JSON file in JavaScript?
- jQuery disable/enable submit button
- Download a file by jQuery.Ajax
- Best way to detect if you are in a SINGLE POST page
- Better way to get tag stats?
- Query two taxonomies via URL or link?
- wp_query order by title
- Sort posts by custom taxonomy name
- Wp_query order by multiple custom fields?
- Would this post meta be better added to the post table rather than post_meta table
- How to properly add Bootstrap and JQuery Javascripts?
- Query Ignoring ‘exclude’ Parameter?
- Get posts for which a custom field is not present, with get_posts
- Output an array of terms for a ‘tax_query’ => array()
- new WP_Query messes up pagination
- Use title of post as argument for query
- JS file is not loading when i put wp_head() and wp_footer
- Different Loop for tag pages?
- WP_Query: attachment image in “full” size?
- Make a products only viewable to a specific user ID in meta_query pre_get_posts
- Exclude parent categories from recent posts list
- custom excerpt is not being shown
- meta_query only check if both value are set
- post_type not working when tag__in is present?
- Optimize WP_Query
- Add a custom variable to query page object
- Help in query for list links
- Search (Custom Form, Custom Search Result)
- Is there another way to retrieve a post_id from post_meta other than a SQL query?