Created
May 29, 2015 13:59
-
-
Save jubstuff/5040ed7209bd2f843126 to your computer and use it in GitHub Desktop.
Create pages in WordPress with Python and Wp-cli
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
Obj1: | |
- Obj21 | |
- Obj22 | |
- Obj23 | |
- Obj24 | |
- Obj25 |
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
#!/usr/bin/env python | |
import os | |
import yaml | |
config = yaml.load(file('config.yml')) | |
for obj1 in config.keys(): | |
print obj1 | |
os.system("wp post create --post_type=page --post_title='%s' --post_status=publish --user=admin --page_template=template-name.php --porcelain" % obj1) | |
for obj2 in config[obj1]: | |
print obj2 | |
os.system("wp post create --post_type=page --post_title='%s' --post_status=publish --user=admin --page_template=template-name.php --porcelain" % obj2) | |
~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment