You’ll have to use JOIN to achieve this:
UPDATE wp_posts p INNER JOIN wp_postmeta pm ON p.ID = pm.post_id
SET p.post_status="draft"
WHERE p.post_type="match" AND pm.meta_key = 'played' AND pm.meta_value = 0;
Related Posts:
- delete custom post based on custom field date
- 1 day after custom date change post status to draft
- How to import database table as custom post type and custom fields?
- Populate custom post type/custom fields from an external database
- Query custom fields with three dates – start and end does not work
- Query & Order posts by custom fields
- Filter custom posts using auto populated dropdown selectors
- How do I associate a custom post type with another through a taxonomy or storing an ID in a custom field?
- Custom post type content using custom fields without template
- Cannot add custom field to “orderby” parameter in Rest API
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- retrieve Meta field value from CPT and set those values as Image Meta Field “Title”
- Having unique constraints for custom fields in a custom post type
- Querying Two Custom Post Types with OR Not Working
- How can I get the number of custom post type posts that have a specific attachment image set?
- Trash / Draft a WordPress custom post after custom date field expires
- Set a maxlength for the title input in a custom post type
- Posting to a Custom Post Type from front end – user generated content
- Display custom fields from custom posts in RSS feed
- Bulk Update Custom Fields for Custom Post Types
- How can I use get_post_meta with add_rewrite_rule to build custom permalinks?
- Visual editor issue by having multiple tiny mce editors in a CPT
- WordPress Custom Fields Won’t Save
- Update Post Meta for a logged in user
- Problem querying Custom post type by custom fields
- Found 2 elements with non-unique id (#_ajax_nonce) and (#_wpnonce)
- Add custom field to Posts and sort by it
- Orderby CPT custom fields not working
- WP_Query order by custom field, then randomly order some of results
- A better way to add a meta box to custom post types
- Rows with custom columns not well formatted after Quick Edit save
- Featured image overlay when changing post status
- Plugin – Combine Meta Box Input Fields into single saveble record
- Two Custom Post Types Many to Many Relationship
- Show custom post type relationships by taxonomy
- get_post_meta not working on publishing
- Query custom post type with ACF Date
- Custom setting to show or hide field
- Custom post type suppress transition from future to publish
- Custom Meta Field – Remove comma from string with str_replace
- Store CPT ‘Reviews’ average ratings to a WordPress DB table or to a DB custom table?
- Using custom field content as expression in IF statement [closed]
- Meta Query Not Returning Output Despite Having Matching Values
- How to create a custom post type with additional fields?
- Callback to custom field is not working in WordPress REST API
- Meta Query Filtering not working on Custom Meta Box using Radio Buttons
- Including metaboxes from custom post types in global search — continued
- ACF From & To Date Validations
- How do I set all of a particular post meta to a value within the custom post type I’m in?
- Query Multiple Custom Posts by Custom Fields
- Show image gallery from a custom field
- Using advanced custom fields from one custom post type in another custom post type / using nested shortcodes
- Dynamic dropdown select values depending on other custom field value
- How to render a custom post type template with custom fields using shortcode
- Disable saving posts as draft (make all posts mandatory regardless of the post status)
- Grouping metadatas into one
- Tracking changes in admin-page so user gets warning when leaving the page
- filter custom post in rest api with custom function
- Get Posts by multiple custom fields is not working
- Woocommerce custom field search in custom post type [closed]
- Update postmeta Parent when post_status child change
- Add custom field in comments form
- Custom Fields for Custom Post [closed]
- Order Custom Post Type by Custom Field Value
- Filter custom post types by a field value
- Displaying All Posts of a Custom Post Type in WordPress Multisite Backend
- Assign External Database Queries to Global Variables and Make Them Accessible
- Repeatable Fields Metabox with Textarea (or wp_editor)
- How to use TinyMCE Editor for one of my custom post meta field?
- Custom REST endpoints for a custom post type with custom fields
- How to import a custom MySQL DB table into a WordPress custom post type
- How to Create a WordPress Plugin With Custom Post Type/Custom Field Features?
- Hierarchy and access control for Custom Post Types (CPT)
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- How to integrate a form (Ninja Form or Contact Form 7) with Custom Post Types?
- Function causing the loop display posting more (empty)
- First custom field value (out of several) displayed twice after query
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Meta Query posts not showing on ending date of custom field
- Cannot save CPT meta box
- Cross reference custom post types
- Removing all post statuses from a Custom Post Type
- Adding Page Templates to post but it ignored it
- Include related custom fields from one post type in another post type’s JSON feed
- Add custom post type drafts to RSS feed
- Admin Custom Meta Box – Pull Last 5 Posts from Custom Post Type
- How to define which register_post_status goes to which register_post_type?
- frontend image post uploader
- Is there any way to add a “custom field” to the CPT archive page?
- How to Output which matched meta_keys were found from custom_type_posts?
- Multiple Frontend Filters Using Advanced Custom Fields
- Custom Post Fields at the beginning of a Custom Permalink
- Integrate Custom Post Type Events into Calendar
- Possible to filter custom post type with multiple meta data?
- Hierarchical custom fields
- How to get a custom field value of a custom post?
- Fields for different parts of a page
- wp_insert_post sometimes fails after API call
- Is it possible to activate customfield ‘text description’ upon activating the customfield ‘checkbox’?
- Facebook social publisher and custom post type fields [closed]