Inline Posts Plugin for Wordpress

Inline Posts

Wordpress lets you create pages that contain static content. The Talks and About pages on this blog are two examples. Unfortunately, until now you could not include posts inside of these static pages. With my new Inline Posts Wordpress Plugin (version 2.1.2g) (2KB), you can!

See the SWX Showcase and SWX documentation pages on swxformat.org for an example of the plugin in use.

In a nutshell

Download and install the plugin and you can include posts in pages (and other posts) by entering the Post ID surrounded by double square brackets ([[nnnn]] where nnnn is the numeric ID of the post you want to include).

Why include posts in pages?

The ability to include posts in pages is something I've felt the need for several times in the past. Basically, the idea is to use posts as sections within a page, with the post title appearing as the section header.

Most recently, I wanted to create the SWX documentation for the SWX homepage as a series of blog posts. This way, each section could have comments on it and I could easily update a single section by editing a post and change the order of sections on the page by changing the order of simple tags that correspond to the posts. I could also show atomic last-modified info for each section so it would be immediately obvious if any sections drift woefully out of date (something that can easily happen to long pieces of documentation).

Since this functionality didn't exist (and believe me, I searched far and wide on the Internets), I decided to roll up my sleeves and try my hand at creating my first Wordpress plugin. It was not a difficult process once I tracked down the hook I needed to latch onto and blew the relearned regular expressions for the umpteenth time.

Installation

  1. Download the Inline Posts Wordpress Plugin (version 2.1.2g (2KB) and unzip it into your wp-content/plugins/ folder.
  2. Log into your Wordpress administration panel, click the Plugins tab, and click the Activate link for the Inline Posts plugin.

Using

  1. Start writing a new page (or edit an existing page)
  2. In the place on the page where you want to include a post, enter the ID of the post, surrounded by double square brackets in the form [[nnn]].

That's it! :)

You can also include posts in other posts using this method (though I'm not entirely sure why you would want to!) And, since pages are really just posts (confused yet?), you can use the Page ID to include a page in a post or a page in another page too if you really feel like that will make your life better! :)

To see an example of it in use, look at the Wordpress page on this blog as you will see this post included in it. Note that this is the first version of the plugin and I'm testing it out as I go. It's only been tested (and not much, at that) on Wordpress 2.1.2. I've tested it on 2.1.2, 2.3.x, and it's running well on 2.5. That said, use at your own risk! :)

I hope this plugin will be as useful for you as it has been for me.

Related plugins

If you'd like your wonderful new pages to show up in searches, install the Search Pages 2.0 plugin. The two plugins work together well but you will get included posts returned as well as the pages in which they are included (which is expected behavior). Even if your pages are entirely made up of posts, having them show up in searches within the context of the page is still useful.

Finally, you may not want the posts that you include in pages to appear on the front page of your blog (or perhaps, not even in your site's feed or in the archives). You can exclude inline posts from these places by using the Ultimate Category Excluder (UCE) by Kyle Slattery. Install this plugin and then put all the posts that you don't want to appear on the main page in a separate category (on SWXFormat.org, I chose "Documentation" as the category to exclude). Then, in the Options panel for UCE, check the "Exclude from Main Page?" option next to that category.

Known issues

For some reason the number of comments on a post is not displaying correctly on Wordpress 2.0.2 (on this blog). It does display correctly with 2.1.2.

Changelist

License

The Inline Posts Wordpress Plugin is released under the open source MIT license.

Comments