Last active
April 24, 2024 09:30
-
-
Save PatelUtkarsh/45cdc740eaa0cb544affb76f1422270d to your computer and use it in GitHub Desktop.
Revisions
-
PatelUtkarsh revised this gist
Apr 24, 2024 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -25,7 +25,8 @@ do # If there are ids to delete, delete them all in one go if [ ! -z "$ids_to_delete" ]; then echo "Deleting terms: $ids_to_delete" # wp term delete post_tag $ids_to_delete --url=$site_url --skip-plugins --skip-themes fi sleep 10 done -
PatelUtkarsh revised this gist
Apr 24, 2024 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -27,4 +27,5 @@ do if [ ! -z "$ids_to_delete" ]; then wp term delete post_tag $ids_to_delete --url=$site_url --skip-plugins --skip-themes fi sleep 10 done -
PatelUtkarsh created this gist
Apr 24, 2024 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #!/bin/bash # Get all site urls site_urls=$(wp site list --field=url) # Loop through each site url for site_url in $site_urls do # Recount all post tags wp term recount post_tag --url=$site_url --skip-plugins --skip-themes # Get all post tags tags=$(wp term list post_tag --fields=term_id,count --format=csv --url=$site_url --skip-plugins --skip-themes) # Initialize empty string for ids to delete ids_to_delete="" # Loop through each line of the output echo "$tags" | tail -n +2 | while IFS=, read -r id count; do # If the count is 0, add the id to the list of ids to delete if [ "$count" -eq 0 ]; then ids_to_delete="$ids_to_delete $id" fi done # If there are ids to delete, delete them all in one go if [ ! -z "$ids_to_delete" ]; then wp term delete post_tag $ids_to_delete --url=$site_url --skip-plugins --skip-themes fi done