Skip to content

Instantly share code, notes, and snippets.

@michael-sumner
Created September 14, 2023 11:17

Revisions

  1. michael-sumner created this gist Sep 14, 2023.
    7 changes: 7 additions & 0 deletions index.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    # replace "Hello, World!" with appropriate string to search for
    # replace `post_title` with appropriate column to search for
    wp site list --fields=url,blog_id | while IFS= read -r line; do
    url=$(echo "$line" | awk -F'\t' '{print $1}')
    blog_id=$(echo "$line" | awk -F'\t' '{print $2}')
    wp post list --field=url --ignore_sticky_posts=1 --orderby=date --order=DESC --post__in=$(wp db query "SELECT ID FROM wp_${blog_id}_posts WHERE post_title LIKE '%Hello, World!%' AND post_status='publish' AND post_type='post'" --skip-column-names --url=${url} | paste -s -d ',' -) --url=${url}
    done >> log.txt