Created
July 12, 2018 07:50
-
-
Save faishal/0d0cb087cf8f31bf64ff24e5e36a8450 to your computer and use it in GitHub Desktop.
WP-CLI script to update / fix all the network site post meta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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