So since attachments
are post types, you should be able to assign them postmeta
like any other post type.
Using the update_post_meta
function should get you where you need to be.
update_post_meta( $attachment_id, 'price', $price );
http://codex.wordpress.org/Function_Reference/update_post_meta
Then run your query based on a meta key.
$args = array(
'order' => 'ASC',
'post_type' => 'attachment',
'post_parent' => $post->ID,
'post_mime_type' => 'image',
'post_status' => null,
'numberposts' => -1,
'meta_key' => 'price',
);
http://codex.wordpress.org/Template_Tags/get_posts#Parameters
Related Posts:
- What is the different between an attachment in wp_posts and an attachment in wp_postmeta?
- How to get meta value in wp_attachment_metadata
- Short of raw SQL, can I query for multiple attachment metadata that have a given array key?
- How does WordPress treats attachments metadata in post content?
- Retrieving post meta array (attachment)
- How can i set media attachments to the author of the post or page for already existed posts with attachments
- Attachment metadata has value of ‘1’
- Create a Gallery and update Post Parent of Attachment Images
- How can I get the post ID from a WP_Query loop?
- How to edit a post meta data in a Gutenberg Block?
- Getting attachments by meta value
- How to update/delete array in post meta value?
- Adding an assisting editor box to Post page
- How do I retrieve multi-dimensional arrays from the wp_postmeta table, & display on a website?
- Get Advanced Custom Fields values before saving [closed]
- adding a URL to a post meta
- ajax delete value from custom field array
- Save attachment custom fields on front end
- update_post_meta() not working when used with WordPress action
- update_post_meta not adding anything.(Nor add_post_meta)
- Get posts by meta value with date
- Identifying Importer Posts
- Get updated post meta on save_post action?
- How metadata API works?
- Delete post meta conditionally after save post
- How to sanitize post meta field value?
- Job of meta_key meta_value fields in database tables
- How to store Gutenberg ColourPicker RGBA as metadata
- Is it possible to update a post meta field through REST API if the format of it when registered is nested?
- How trigger to save post when updating post meta
- Create a Metabox that behaves Like a Taxonomy Box
- Query 2 meta key values and a category
- trying to do if post meta !=0
- Trying to get file name
- order by multiple meta_keys?
- how to build (custom) stats for post views, per month
- get_post_meta pagination
- Removing Post Meta from Category Pages?
- Hey, I want the second options. get_post_meta()
- Update post meta in woocommerce order frontend
- get_*_meta doesn’t always return an array
- populate post meta in gravity forms [closed]
- How can I convert postmeta from unserialized to serialized?
- How to display post view count by date, week and month?
- How can I filter posts when the meta_value is a serialize object?
- Get User Post if Private
- How to receive all the meta information of a post ?
- Unknown characters added to meta data values
- Compare old meta with new post meta
- get_post_meta($post->ID) returns empty string when in preview mode of custom post type
- How to update the title of audio file through its attachment metadata
- need to add add user names to the post for later retrieval or removal
- Custom query, multiple custom keys
- Trying to get property of non-object error using get_post_meta()
- Like & Dislike functionality using JavaScript
- How can I change the tag contents of individual WordPress posts?
- get_post_meta producing white screen of death
- get_permalink vs the_permalink
- Look up all posts by status or meta value – performance difference
- Updating my Post when expiry date is past
- How to remove Date from Meta Description on SERP?
- Can A Post Meta Field Store multiple values that are not in an array?
- esc_attr on get_post_meta [closed]
- How to display sql query fired by posts_where
- Unfiltered html with update_post_meta
- get meta value from page query
- Sort custom posts in archive by multiple values: date AND meta key
- why after saving meta value it’s saving all the values the one that i clicked?
- How is the author’s name given a different color?
- URL to Post Meta [closed]
- Why is variable that get_post_meta stored in empty?
- Front end file upload returning wrong attachment url
- get_post_meta in one post only
- Displaying the ‘time ago’ for recent activity within a post/custom post type?
- add post meta front end edit
- How to query and update one colum in postmeta table?
- How to remove date from showing in meta description
- How to save HTML data into SQL post_content column
- update post meta value with other post meta value
- Check For get_post_meta on Author Archive Page
- Negative meta_query if storing multiple post_meta values with shared meta_key
- How can I update this array built from post meta data?
- What format is this and how to get value “lal” and “pila” from it
- Frontend query and does not need to log in [closed]
- Get data from custom table and update relative post_meta based on meta_key
- Custom attachment function not working in v5.4.2?
- How to get the total of two meta values from different meta keys?
- How to save a meta_value as a numeric value after I retrieve it via update_post_meta?
- Programatically delete several attributes in _product_attributes in post meta
- Get post meta after insert post
- Data not displaying in text field
- How do you sort the items in a custom taxonomy meta box?
- WP-API + JS Backbone client – how to update post meta
- Delete custom post type metadata without deleting the post in admin area
- Proper Way to Sanitize Meta Input
- update_post_meta returning false when called during init
- How to get pictures of the WordPress post
- Access Serialized Post Meta Values
- Cache metadata for set of posts
- Problem with get_post_meta