Skip to content

Instantly share code, notes, and snippets.

@faishal
Created July 12, 2018 07:50
Show Gist options
  • Save faishal/0d0cb087cf8f31bf64ff24e5e36a8450 to your computer and use it in GitHub Desktop.
Save faishal/0d0cb087cf8f31bf64ff24e5e36a8450 to your computer and use it in GitHub Desktop.
WP-CLI script to update / fix all the network site post meta
#!/bin/bash
for SITE_URL in $(wp site list --fields=domain,path,archived,deleted --format=csv --url=MAIN_DOMAIN | grep ",0,0$" | awk -F ',' '{print $1 $2}')
do
echo "Fixing $SITE_URL ..."
for POSTID in $(wp post list --post_type=CUSTOM_POSTTYPE --field=ID --url="$SITE_URL")
do
wp post meta update ${POSTID} META_KEY NEW_META_VALUE --url="$SITE_URL"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment