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!
- Custom Meta Boxes – Nonce Issue – Move to trash issue
- How to localize value of posts
- Custom metabox translation
- Limit Authors to their Own Posts on front-end excluding admins
- How to get only one category of custom post type?
- How to stop wordpress from mangling HTML in a metabox textarea
- How can I programmatically save data into custom fields that contain serialized data?
- Adding a span when custom post type is updated
- How to add meta boxes(repeater fields) from WordPress back end?
- Displaying Meta Box Image
- Custom Scripts per page or Custom Post Type
- Change Post Title Edit Box
- How do you use JavaScript to detect the homepage
- Inserting data into `post meta` table?
- How to customize the Categories meta box to allow only one category?
- Relate two custom post type using meta box
- Error after deleting Custom Post Type with a function (no trash used)
- Custom Post Type Meta Boxes
- WordPress is executing URL in code when called via wp_mail()
- Get all taxonomies for all post types
- How to redirect all pages of a custom post type [duplicate]
- Hiding Metabox from Screen Options Pull Down
- Row actions not showing? Why?
- Displaying custom post type on front page
- Multiple information using custom post type
- Append taxonomy terms as class names in markup?
- How to: add option to add more checkboxes on custom post type
- How to keep a check box in custom meta box for custom post type checked by default for add new post?
- How to add multiple featured image in meta box in post editor?
- Custom Post Type .current-menu-item not applying on Custom Post Type Archive Page
- Show metabox in custom-post-template depending on taxonomy term?
- How do you output custom code between posts in the loop?
- Show ACF field from custom taxonomy and display on the single template
- How to allow “Add New” capability of CPT when links to its UI are placed as a submenu?
- Change message given when deleting post from custom post type
- Display children and grandchildren of a custom post type
- get_terms won’t display product_cat or any other custom taxonomies when specified
- how to set default value for checkbox in wordpress
- How to append element after thumbnail
- WordPress Rest API only returns content when posttype has editor capability
- wordpress custom post type remove duplicate menu item
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- Timepicker-addon doesn’t show – Datepicker works fine?
- is_page_template not working as expected
- Displaying custom posts only if custom meta box’s date is not expired
- List terms from Custom Taxonomy
- Display custom post on home page based on a metabox selection
- Displaying Metabox value (custom post type taxonomy)
- Hide Meta Boxes for Non-Admins
- How to add a “custom” date field to a custom post type?
- WP_Query search posts by custom post type and custom taxonomy
- Adding Meta Boxes while Registering a Post Type in a Class
- Dynamic Custom Post Type Plugin
- Order WordPress Custom Taxonomy Pages & Pagination Not Working
- I am having a problem with form updating/editing WordPress post on the frontend
- How to filter out post type meta?
- How to make in WordPress admin panel sortable column for the custom field, that count the number of page impressions?
- adding checkbox to meta
- How can I display my custom metaboxes on a custom post template?
- Display custom field of specific post where post title matches variable
- Conditional to modify query results
- Meta Box Only in CPT Edit Page, Not in Add New
- Loop through posts of a custom-post-type (event) and create .ics (iCal) file?
- Output custom post shortcode. Help spot the error.
- How to count custom post types with conditional operators
- get_post_meta is returning image id
- Metabox Populated with a Custom Post Type – How to Output CPT based on Select?
- Is it possible to create a post using a metabox?
- WP_Query is printing out only one post when posts_per_page is set to multiple
- WP Query to displaying date and posts for that date?
- GravityForm: Populate Dropdown with custom post type [closed]
- Return array of categories to php function for current post
- Link users to a custom post type
- Create a random unique 6 digit number as custom field for custom post type
- How to output wordpress custom tags separated by comma?