-
-
Save jplhomer/646927e569548bca4f4e to your computer and use it in GitHub Desktop.
$ wp post list --format=ids | xargs wp post update --comment_status=closed | |
# Output: | |
# Success: Updated post 2514. | |
# Success: Updated post 2511. | |
# Success: Updated post 2504. | |
# Success: Updated post 2499. | |
# Success: Updated post 2441. | |
# etc... |
$ wp post list --format=ids | xargs wp post update --ping_status=closed | |
# Output: | |
# Success: Updated post 2514. | |
# Success: Updated post 2511. | |
# Success: Updated post 2504. | |
# Success: Updated post 2499. | |
# Success: Updated post 2441. | |
# etc... |
Also, if you want to disable them by default, this should turn them off:
wp option update default_pingback_flag ""
wp option update default_ping_status ""
wp option update default_comment_status ""
This method is a bit faster if you have many posts and not all of them need the change:
$ wp post list --comment_status=open --format=ids | xargs wp post update --comment_status=closed
...
$ wp post list --ping_status=open --format=ids | xargs wp post update --ping_status=closed
...
If you like to toggle them for Posts only then here is the quickest way.
wp post list --post_type=post --comment_status=open --format=ids | xargs wp post update --comment_status=closed
wp post list --post_type=post --ping_status=open --format=ids | xargs wp post update --ping_status=closed
Disabling pings and comments can be simplified into one command:
wp post update $(wp post list --format=ids) --ping_status=closed --comment_status=closed
Also, if you want to disable them by default, this should turn them off:
wp option update default_pingback_flag "" wp option update default_ping_status "" wp option update default_comment_status ""
I would share these with closed
, yes and empty string will end up as closed
in the database, but I think it's confusing. Setting them with true
or 1
will NOT enable them back on, you need to use open
. It's not a boolean, as I thought originally.
I just made a little post about it as I ran into this and dug deeper.
Thanks!