How I created ProBlogger’s “Group Writing Project” WordPress plugin

Posted by Gary King on June 13, 2007
Categories: programming, web

problogger-logo.gifA few weeks ago, Darren from ProBlogger asked me to create a new WordPress plugin for him, one which would save him countless hours that he had to spend before. That plugin is the Group Writing Project plugin, which is now used to help simplify the process that Darren has to go through whenever he decides to start a new project.

I’ve posted about the non-technical side of the plugin and the benefits that he gained from the plugin before, so in this post, I will walk through how a plugin like this is created, and the typical workflow and thinking that goes behind creating something like this.

This is a WordPress plugin, but it uses some special WordPress functions that I have never seen used in an existing plugin before. Hopefully this post will inspire WordPress plugin developers to use these functions more in future plugins.

The most important thing about the plugin is the wp_insert_post() function that I use. This is used to create new posts in the blog, just by using code and by passing an array to it, containing the data necessary.

The plugin basically revolves around this one function, because when a new item is submitted with the GWP (Group Writing Project) form on ProBlogger, it actually modifies an existing post. It determines which post to modify based on the post’s title, which is currently Group writing project - LATEST.

The wp_insert_post() WordPress function is not documented at all, so I’ll explain how it’s used. It helps if you already know how to use general functions in PHP.

When using wp_insert_post(), you need to pass an array as the first and only argument to it, like so:

wp_insert_post($post);

$post is an array that must contain at least the following keys:

  • post_author: the user ID of the blogger who is the post’s author; I set this to Darren’s ID
  • post_title: the title of the post. If this is not set, I believe the post’s title is set to the ID number of the post
  • comment_status: set this to either ‘open’ or ‘closed’; it will most likely be ‘open’
  • post_content: the body of the post. This can be blank.
  • ID: this is optional, but if it is set to an existing post’s ID, then you will be modifying an existing post instead of creating a new one.

That’s all you need to get it working. I hope the above has helped you out with your WordPress plugin endeavors!

Popularity: 25% [?]

Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

  1. adSearch, making the most of your website. Tuesday, November 30 1999 at 12:00 am EST #

    links from TechnoratiDynamic Keyword Checker Tool to check the effects of running dynamic keywords in your Google pay-per-click ads. Dynamic Keyword Insertion - The Ultimate Guide Useful reference for improving Pay-Per-Click campaigns. How I created ProBlogger’s “Group Writing Project” Wordpress plugin development, including a useful tip on inserting posts into the database.

  2. links from TechnoratiHow I created ProBlogger’s “Group Writing Project”

  3. links from Technorati hooks are: those things you have to remember to add to your header to stop plugin authors yelling at you. More technically, they’re a way of adding to or altering the content … Extralogical - http://extralogical.net How I created ProBlogger’s “Group Writing Project” WordPress plugin By Gary King A few weeks ago, Darren from ProBlogger asked me to create a new WordPress plugin for him, one which would save him countless hours that he had to spend before. That plugin is the Group Writing Project plugin, which is now used to help

  4. Chris Garrett Tuesday, June 19 2007 at 5:57 am EDT #

    Great stuff, I think you should post more about wordpress development :)

  5. Gary King on Wordpress Plugin Development @ chrisg.com Tuesday, June 19 2007 at 6:00 am EDT #

    [...] has written a post about his “Group Writing Project” WordPress plugin that should be interesting to anyone involved in Wordpress hacking and plugin development. Most [...]

  6. Rob Lewis Tuesday, June 19 2007 at 6:28 am EDT #

    Nice tip Gary, wish I’d known about that before, rather than inserting posts using my own sql statements.

  7. StumbleUpon » Your page is now on StumbleUpon! Tuesday, June 19 2007 at 9:49 pm EDT #

    Kramer auto Pingback[...] Your page is on StumbleUpon [...]

  8. Gaje Master Friday, July 13 2007 at 2:14 pm EDT #

    I love the wordpress plugins that you come up with. I will be reading more of your work.

Comments



Close
E-mail It