Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A smart and simple python library with a cli to post to wordpress blogs.
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

My reseach group maintains a wordpress blog as our lab notebook. Leaving the terminal to go make a post was disruptive to my workflow and resulted in limited use of the blog. I wrote pypress so that I could post markdown files, ipython notebooks and other file formats directly to a wordpress blog and upload the media they contain with a single command.

Titles, tags and categories can be specified on the command line or in files using html comment syntax. Multimarkdown is used to convert markdown to html, so Mathjax is supported with markdown math syntax - \(( mathy bits \\) for inline math and \\[ mathy bits \\] for display math. Once a file has been used to create a post, that post can be updated by just running the same command again. Media is not reuploaded unless it has been modified.

Making a post is as easy as

$ wpup -f -T "Look mom, no mouse!" -c tests -t pypress

This will make a post titled "Look mom, no mouse!" in category "test" with a tag of pypress and content contained in If you changed the content of, you can simply edit the post from the command line by running

$ wpup -f -T "Look mom, no mouse!" -c tests -t pypress


$ wpup -f -b -u benjaminaschultz

This will make a post containing the contents of, and title, tag and categorize the post using comment tags contained within In this example, you will post to, rather than from your ~/.pypress-config.json file.


pypress contains a couple of convenience classes and scripts so that blog and post defaults can be handled read from a config file, as well as prompt the user for a password before posting so that your password doesn't need to be stored in a file anywhere.

This script will batch upload media to your wordpress blog

usage: [-h] [-b URL] [-u USERNAME] [-p PASSWORD] files [files ...]

This script will batch upload markdown, txt, ipython notebooks and html files to your wordpress blog, automatically uploading any images and fixing image links. Direct uploading of markdown files requires multimarkdown

usage: [-h] [-b URL] [-u USERNAME] [-p PASSWORD] [-T [TITLES [TITLES ...]]] [-t [TAGS [TAGS ...]]] [-c [CATS [CATS ...]]] [-s STATUS] -f FILES [FILES ...] [--show] [--post_type TYPE]


Begin by installing my fork of Max Culter's python-xmlrpc library

git clone
cd pypress
sudo python install

Then install the wordpress helpers package

cd ../
git clone
cd pypress
sudo python install

I recommend adding some aliases to the scripts to your bashrc (e.g.)

#pypress aliases
alias wpcp='/path/to/pypress/scripts/'
alias wpup='/path/to/pypress/scripts/'

If you plan to use mathjax and markdown together, please install multimarkdown. There are mac installers available here, or you can compile from source if you're a linux user (git repo)

If for whatever reason you can't get multimarkdown working, you can use python's markdown2 library, but math syntax will not work.

sudo apt-get install python2.7-pip


sudo port install py27-pip


sudo pip install markdown2

Next we want to put the config file in place so that the scripts know who you are and where you want to blog to without supplying command line args every time..

cp examples/pypress-config.json ~/.pypress-config.json

Edit the config file with your username, blog url, default post settings, etc.

Basic behavior

Read all about markdown syntax here..

When you use these scripts to upload a markdown file e.g.,

$ wpup -f -b https://blogthatoverridesconfile/ -u me

The following things happen:

  1. The command line args are parsed and override any settings in your ~/.wp-helpers.json file
  2. Your markdown file is converted to html with multimarkdown
  3. An xmlrpc client connects to the blog
  4. The html text is parsed for images, title, tags, categories, a "more" tag and math content
  5. Images are renamed by their md5 sum and uploaded to the server if they do not exist already

    • Note: To cut down on the amount of data sent back from the server, only the 50 most recent media items are checked against the media contained in a particular post
  6. Image links are replaced by links to media on the server

  7. If this post does not contain a "more" tag, one is inserted to prevent large posts takings over the blog.
  8. If this post contains math, a [mathjax] flag is added to the beginning of the post so WP knows to render equations.
  9. Posts by this user are retrieved. If a post has previously been created using this file, then it is updated by default, but this behavior can be overridden. Otherwise, a new post is created.

New Features

Eventually I'd like to add support for:

  • LaTeX in some form. WordPress doesn't like the html that htlatex creates, and multimarkdown and mathjax work pretty well for now
  • I'd love to get support for wordpress's secure_xmlrpc plugin working. This would allow you to safely post to blog without typing in your password and without storing your wp password anywhere.
Something went wrong with that request. Please try again.