Created
March 17, 2020 08:56
-
-
Save mrrcollins/88bb6be29e6728de74bbb11c0ae9a1fe to your computer and use it in GitHub Desktop.
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 | |
# Requires wp-cli installed and a wp alias set up for each site | |
if [ -z ${@} ]; then | |
echo "Usage: createpost @SITE FILENAME" | |
exit | |
fi | |
site=${1} | |
postfile=${2} | |
posttitle=$(cat ${postfile} | grep ^Title | cut -d ":" -f 2 | xargs) | |
echo "Creating post '${posttitle}' from ${postfile}..." | |
wp ${site} term list category --fields=id,name,slug | |
echo -n "Category? " | |
read -e category | |
echo -n "Tags? " | |
read -e tags | |
echo -n "Create post (y/n)? " | |
read -e yesno | |
if [ ${yesno} == "y" ]; then | |
cat ${postfile} | wp ${site} post create - --post_category=${category} --post_title="${posttitle}" --tags_input="${tags}" | |
git mv ${postfile} ../Archive/`date +"%Y"`/ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment