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
- JQuery UI Autocomplete/Autosuggest WordPress
- How to show custom fields in modal in category page
- How To Call WP_Query From A Subdomain?
- active link for most recent post on vertical tabs
- How to allow Readers to Select Post Order?
- Extending WP Query: Custom geolocation meta values work, but tax_query breaks
- Why I’m Not Having Access to “$_POST” Data Outside My AJAX Callback?
- WordPress Bootstrap Grid
- comment-reply.js disables any other form javascript
- 2 Loops on one page – pagination of 2nd loop ignore array of excluded posts
- WordPress: Cron locking and Queue
- wp_get_attachment_image not to get the post_thumbnaill
- Connecting a wordpress site to an AngularJS APP
- Random posts in WP_Query when searching by tag
- How To Use WP_Query To Get The Custom Post type Posts With Keywords
- Empty ‘terms’ in ‘tax_query’ returns an empty array
- WP Media Uploader modal conflicts with Bootstrap modal
- JQuery and Javascript to pan image
- WP_Query with child element
- Custom Theme Building & Permalinks
- Include post_status check within $wpdb query
- Add a downloaded JS file to WordPress
- Pagination returns 404 after page 20
- How to order by datediff in WP loop?
- Select posts wich has no relationship in custom taxonomy
- Query with two posttypes and two different meta_keys
- Custom query for tag and custom tag from 2 post type
- Sort by meta key within same day
- wpdb get_results() returns only 2 rows