Skip to content

Instantly share code, notes, and snippets.

@jubstuff
Created May 29, 2015 13:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jubstuff/5040ed7209bd2f843126 to your computer and use it in GitHub Desktop.
Save jubstuff/5040ed7209bd2f843126 to your computer and use it in GitHub Desktop.
Create pages in WordPress with Python and Wp-cli
Obj1:
- Obj21
- Obj22
- Obj23
- Obj24
- Obj25
#!/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