Creating a Custom Post Type for Inserting Preset Content into Post & Pages?

Your question got me thinking about extending your use-case to a plugin I published earlier called WP Boilerplate Shortcode. I know your question isn’t about shortcodes but the name is only legacy for your use-case; indeed my extension I just added because of your question will do (almost) exactly what you are asking for (I’ll explain the “almost” part below).

I’m going to have to come back and document this more in-depth but I figured I’ve give you first access to it sooner than later (note the instructions.txt file does not address the new features yet):

The easy part of doing what you ask was the back-end coding; the harder part was figuring out a good UI. If there are multiple content items to choose from the user needs a way to select which one to use and there’s not one obvious way to do that.

One approach I could have used would have been to intercept when the user clicked “Add Post” and ask them which pre-populated content item they want to start with but that seemed kludgy and not in line with how the WordPress admin normally works. So instead I added a “Insert Boilerplate” metabox with a dropdown containing the list of available boilerplate text items.

To use this plugin download, copy to a subdirectory in your /wp-content/plugins/ directory and then activate it. After activation look for the “Boilerplate” menu and start adding your sales Letters as Boilerplates being careful to selecting the “Associated Post Types” for which you want each Boilerplate to be active. Then in the “Add {post type}” window in the admin look to the top right; you’ll find the content from the boilerplate to the end of whatever is currently in the content editor:

Screenshot of WordPress 3.0.1 and the Metabox from WP BoilerPlate Shortcode v1.0.5
(source: mikeschinkel.com)

Note that upon activation the plugin will add any post types you might have into the “Associated Post Type” taxonomy but if you add new post types later you’ll have to add them manually; just make sure to match exactly the plural name of the post type (i.e. “Products” or “Featured Posts” or whatever.)

This isn’t exactly what you asked for but given the need for a way to select content I think it’s a really workable solution. I’d love to get your feedback on what you think of it.

Leave a Comment