Inline Posts Plugin for Wordpress
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!
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.
- Download the Inline Posts Wordpress Plugin (version 2.1.2g (2KB) and unzip it into your wp-content/plugins/ folder.
- Log into your Wordpress administration panel, click the Plugins tab, and click the Activate link for the Inline Posts plugin.
- Start writing a new page (or edit an existing page)
- 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.
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.
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.
- Version 2.1.2g: (August 28, 2007) Added automatic table of contents (TOC) creation for pages. If you want the TOC included in a page, use the tag [[ TOC ]] (without the spaces). Also added Top anchor links for easy navigation from TOC to topics and back.
- Version 2.1.2f: (August 27, 2007) Anchor tags are now added to topic headings so you can link to specific topics on a page in the form: http://myblog.com/somepage/#post_id as in the following example: http://swxformat.org/documentation/#85).
- Version 2.1.2e: (August 25, 2007) The plugin now removes HTML comments and the linebreak before the initial double bracket so that these don't cause Wordpress to display additional <br /> tags in the output.
- Version 2.1.2d: (August 25, 2007) Raised priority of the plugin so that it doesn't conflict with other plugins like the CodeHighlighter plugin. Also removed an error_log trace that would have resulted in large log files (the plugin no longer outputs any debug information).
- Version 2.1.2c: (August 24, 2007) Added "Edit Topic" links so you can edit an included post in a page without having to click through to that post first.
- Version 2.1.2b: Added admin panel and option to set the tag that the titles of posts are displayed in (h2, h3, etc.)
- Version 2.1.2a: Changed default tag to [[nnn]] from [nnn].
- Version 2.1.2: First release.
The Inline Posts Wordpress Plugin is released under the open source MIT license.