You need to loop through your posts, and retrieve the metadata for each post. Add them to your array, and encode them to JSON.
$posts = $query->get_posts();
foreach( $posts as &$thispost ) { // reference the current item
$thispost->meta = get_post_meta( $thispost->ID );
}
Now you got a WP_Post
-Object, with all the post meta available at $post->meta['meta_key'][0]
. If more than one value is saved for a meta key, you can loop through the ['meta_key']
-Array.
Related Posts:
- Using ‘strtotime’ function to convert a custom-meta-box to a date-stamp
- How to save the checked boxes?
- Calculate Repeater Meta Box Input Field Values and Display Total
- How to create a repeatable / reusable divs in the metabox?
- wp is not defined error using wp.media to create a custom image uploader
- Using WPAlchemy metabox values in another metabox
- A good strategy to print custom posts (offer) that are checked inside the metabox of a post?
- What’s the difference between same wp functions get_posts(); functions in different form?
- Troubles with saving metabox
- Why are taxonomy terms not saving when using custom meta boxes with radio button taxonomy selectors?
- Plugin – Combine Meta Box Input Fields into single saveble record
- How to Upload CSV Data into Custom Post Type Data with Metabox programmatically
- How can I move (or create another) publish button?
- Add additional field to custom post_type
- Meta-Boxes for CustomPostType cause PHP Errors and Notices in “Add New” view
- Get data from PHP to JavaScript to set position of each post on front page
- Create a Dropdown Selector and Redirect for a Custom Taxonomy in WordPress?
- I’m having trouble with Related Product “tax_query” ‘terms’ value
- How to use posts as tabs in a custom page?
- Get meta values from parent post and save in child post
- How to make sure, that only the selected post is changing?
- Meta box not saving
- Meta Box not being added in plugin
- Meta-Box to add multiple items one at a time and on publish save all
- Just the First Metabox what saves the data!
- Display a query with multiple post types and same relationship on a single page
- WordPress Custom Post Types with a page as a parent?
- Add metabox with media uploader in a custom post type [duplicate]
- Removing Edit Permalink/View “Custom Post Type” areas
- Unable to save custom taxonomy terms in a custom-built metabox
- How to sort CPT by custom meta value (date), and return posts month by month
- How can I include meta box content when searching?
- Limit Authors to their Own Posts on front-end excluding admins
- How to redirect all pages of a custom post type [duplicate]
- Show ACF field from custom taxonomy and display on the single template
- How can I display my custom metaboxes on a custom post template?
- Custom Post Type with metaboxes (no content) only?
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- Unable to show meta box data in frontend
- Get Post Primary Category
- Can’t get order_by meta_value_num to work properly
- Create custom post type on successful woocommerce order [closed]
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- Adding dropdown select meta box to custom post type – seems restAPI is interfering
- How to make sure content doesn’t display if selection is empty
- How to make a field appear only if a post meta field has a defined value?
- Why is my select meta data not saving?
- Redirect 404 page with ID in slug to associated page with same ID in slug
- Grouping metadatas into one
- Anon function and add_meta_box
- Can custom fields be added without a meta box?
- Meta Box on Custom Post Type not saving
- Redirect to another page using contact form 7? [closed]
- Different options per post type in WP_Query
- Values from meta-box not on $_POST
- How do I create a new post upon registration with the users first and last name as title
- Get id from metabox dropdown
- Creating a non-hierarchical Taxonomy that behaves like categories
- Custom Ratings for Theme, Proper way to Refactor Code and Clean up Template File
- How to set the mainpage of a custom post type?
- Custom posttype content metabox
- Using Wp_Query, Json to add Highcharts series data
- How can I output WPAlchemy repeating fields meta values in my page template?
- Displaying One Custom Post Type’s Content On Single Post of Another Custom Post Type
- Questions regarding add_meta_box()
- Let users upload image(s) to the post from front end
- Using page title as a link to term archive
- How to display custom post type only on a certain page?
- Setup page template array in a custom post type
- How do I ensure that post_type and Taxonomy use the same slug?
- Metaboxes inside Tab
- Change Dropdown jQuery to show/hide but with default place holder that shows all
- Custom Post Type meta data getting deleted on bulk editing taxonomies
- What is the best way to set the post category (Custom Post Type) automatically based on the one of the tags assigned to the post?
- Show a custom post title in another custom post type in Meta box
- How can I use javascript in specific posts without relying on a plugin?
- Modify Publish Metabox location on CPT
- Set a template on a custom post in the plugin
- PHP Warning with Custom Fields
- Do not show child pages within a file page
- Custom search for a custom post type in WordPress
- Custom taxonomy with custom post type archive page
- How to mix 2 kinds of post types
- How to shows CPT which has specific meta key?
- wp_dropdown_pages doesn’t allow me to select more than one custom post type
- Delete custom post type metadata without deleting the post in admin area
- Metabox is not saving
- Loop carousel slider in wordpress
- Custom Post save causes 500 error
- Not Able to Display Metabox Saved Checkbox and Selected option After Save/ Update
- Function not pulling image or text from custom post type
- WordPress Custom Post Type and sort by Tags
- Select custom post by meta value
- Looping taxonomy in taxonomy?
- Permalink of Custom Post Type
- posting twice from an array?
- How do I filter a custom post type loop by a field?
- How to manage wordpress knowledge base/wiki/posts collections
- Display div based on Group metabox selection [closed]
- Getting ACF relationship field information