Created
August 3, 2018 16:42
-
-
Save mgratch/a5c486d4f9edd7e2e2b3c073fcbf1910 to your computer and use it in GitHub Desktop.
Loop through all the blog posts and mark the first 4 as featured. Using variables, loops wp-cli, conditionals.
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 characters
// loop through all the blog posts and mark the first 4 as featured. | |
i=0; \ | |
c=4; \ | |
for id in $(wp post list --format=ids); \ | |
do let i++; \ | |
if [ "$i" -lt 4 ]; \ | |
then wp post meta update $id featured_post '1'; \ | |
else wp post meta update $id featured_post '0'; \ | |
fi; \ | |
done; \ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment