admin管理员组文章数量:1130349
I have:
CPT: match custom field: played
Is it possible by MySql to change the status from publish to draft of all posts of CPT 'match' with custom field set as '0'?
A good start can be
UPDATE wp_posts SET post_status = 'draft' WHERE post_type = 'match' AND meta_key = 'played' AND meta_value = 0;
but meta_key and meta_value are not in wp_posts table.
Thanks a lot for your support
I have:
CPT: match custom field: played
Is it possible by MySql to change the status from publish to draft of all posts of CPT 'match' with custom field set as '0'?
A good start can be
UPDATE wp_posts SET post_status = 'draft' WHERE post_type = 'match' AND meta_key = 'played' AND meta_value = 0;
but meta_key and meta_value are not in wp_posts table.
Thanks a lot for your support
Share Improve this question edited Dec 5, 2018 at 19:06 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Dec 5, 2018 at 17:47 GiulioGiulio 511 silver badge8 bronze badges 01 Answer
Reset to default 0You'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;
I have:
CPT: match custom field: played
Is it possible by MySql to change the status from publish to draft of all posts of CPT 'match' with custom field set as '0'?
A good start can be
UPDATE wp_posts SET post_status = 'draft' WHERE post_type = 'match' AND meta_key = 'played' AND meta_value = 0;
but meta_key and meta_value are not in wp_posts table.
Thanks a lot for your support
I have:
CPT: match custom field: played
Is it possible by MySql to change the status from publish to draft of all posts of CPT 'match' with custom field set as '0'?
A good start can be
UPDATE wp_posts SET post_status = 'draft' WHERE post_type = 'match' AND meta_key = 'played' AND meta_value = 0;
but meta_key and meta_value are not in wp_posts table.
Thanks a lot for your support
Share Improve this question edited Dec 5, 2018 at 19:06 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Dec 5, 2018 at 17:47 GiulioGiulio 511 silver badge8 bronze badges 01 Answer
Reset to default 0You'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;
本文标签: Sql Update CPT from publish to draft and particular custom field
版权声明:本文标题:Sql Update CPT from publish to draft and particular custom field 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749125747a2319751.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论