{"id":1121,"date":"2023-08-11T16:06:18","date_gmt":"2023-08-11T21:06:18","guid":{"rendered":"https:\/\/ma.rcbla.se\/blog\/?p=1121"},"modified":"2023-08-11T16:09:20","modified_gmt":"2023-08-11T21:09:20","slug":"delete-post-revisions-in-wordpress-with-wp-cli","status":"publish","type":"post","link":"https:\/\/ma.rcbla.se\/blog\/2023\/08\/delete-post-revisions-in-wordpress-with-wp-cli\/","title":{"rendered":"Delete post revisions in WordPress with wp-cli"},"content":{"rendered":"<p>Easily remove revisions using wp-cli. First, get a list of revisions with:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ wp post list --post_type='revision' --format=ids\r\n<\/pre>\n<p>This command will provide a list of revisions by post ID.<\/p>\n<p>To remove those revisions, use to following command:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ wp post delete $(wp post list --post_type='revision' --format=ids) --force\r\n<\/pre>\n<p>This command will provide feedback to stdout as <code>Success: Deleted post XXX.<\/code> Where XXX is the post ID of the deleted post. The <code>--force<\/code> flag may not be necessary, but was in my case since the command failed with the warning: <code>Warning: Posts of type 'revision' do not support being sent to trash.<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Easily remove revisions using wp-cli. First, get a list of revisions with: $ wp post list &#8211;post_type=&#8217;revision&#8217; &#8211;format=ids This command will provide a list of revisions by post ID. To remove those revisions, use to following command: $ wp post delete $(wp post list &#8211;post_type=&#8217;revision&#8217; &#8211;format=ids) &#8211;force This command will provide feedback to stdout as [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-1121","post","type-post","status-publish","format-standard","hentry","category-coding"],"_links":{"self":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts\/1121","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/comments?post=1121"}],"version-history":[{"count":6,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts\/1121\/revisions"}],"predecessor-version":[{"id":1128,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts\/1121\/revisions\/1128"}],"wp:attachment":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/media?parent=1121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/categories?post=1121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/tags?post=1121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}