You could use GNU find and GNU xargs to search for the wp-content directories and pass the result NUL-terminated to a shell script:
find /path/to/directory -type d -name 'wp-content' -print0 | xargs -0 sh -c '
for dir; do
# change user and group recursively to nginx
chown -R nginx:nginx "$dir"
# change dirs to 755
find "$dir" -type d -exec chmod 755 {} +
# change files to 644
find "$dir" -type f -exec chmod 644 {} +
done
' sh
Alternatively, you could save the script part in a shell script myscript.sh:
#!/bin/sh
for dir; do
# change user and group recursively to nginx
chown -R nginx:nginx "$dir"
# change dirs to 755
find "$dir" -type d -exec chmod 755 {} +
# change files to 644
find "$dir" -type f -exec chmod 644 {} +
done
Then make the shell script executable with
chmod +x myscript.sh
and run find (not necessarily the GNU implementation) using the -exec action and pass the result to the script:
find /path/to/directory -type d -name 'wp-content' -exec ./myscript.sh {} +