wp-cli post --post_type=attachment list --format=count
For all multisite sites
wp-cli site list --field=url | while IFS= read -r line; do url=$(echo "$line" | awk -F'\t' '{print $1}'); echo ""; echo "";echo $url; echo "";wp-cli --url=${url} post --post_type=attachment list --format=count; done;
Source: https://shortcode.dev/wp-cli/count-all-posts.html
Leave a Reply