WordPress front-end post form using wp_insert_post

At WordCamp Austin, I hosted an awesome Q&A session about the underbelly of Android and Me. One of the most requested bits of code was the form action utilizing wp_insert_post().

(I was leading a session on wp_insert_post() at the time, the slides for which you can find here.)

If you’re not aware, we recently launched a featured on Android and Me called Threads. Threads allow users with enough points (oh yeah, our blog runs on a point system, too- take notes!) to create a post directly from the front-end of the site, never seeing /wp-admin. While my production implementation is quite a bit more complex than this, below I’ve shared a stripped down version of the functionality. Join me at the bottom for some extra, dirty details.

[code id=”635″]

If you’d like to see a preview of the whole thing, go create an account on Android and Me, toil through the ranks, earn some influence, then make a thread. Orrrr, you can check out a preview over on Forrst. I’d love to show you the live page, but it really is for power-users only. In the preview you’ll also notice we’re doing some neat things like charging for creating threads and using a custom editor via MarkItUp, but I left out all that stuff in the above example. The finesse is up to your imagination.

Along with the above snippet, please go study the wp_insert_post() codex page. There, you’ll find all the arguments and settings you’ll need to insert just about any damn post you can imagine. Any post type, any author, with any meta, from anywhere on your site. Think about that.

PS: I haven’t tested the above stripped-down snippet by itself, so take it with a grain of salt. Use it as a springboard, not a copy & paste solution.

PPS: The above snippet can also be found on Gist, ripe for forking.

DATE24th May, 2012




  1. Awesome tutorial… 🙂

  2. John

    Hi Clark, thanks for the head start on wp_insert_post()! I wasn’t able to see the slides from your discussion of the subject at WordCamp. Can an updated link be shared?

  3. ems

    Hi, does this account for the after post refresh issues with re-submitting the form data and the use of the back button?

  4. How can we retrieve the tags which we are storing.

Leave a Reply