WordPress Plugin: Arbitrary Shortcodes

For a new project, I’m working on launching a large number of very similar WordPress installations with minimal effort. I needed a way to have WordPress automatically parse some kind of template tag or shortcode (like “[client_name]”) across all the different pages on the site. Not only that, I needed the field’s values to be easily updated in one place, and there would be an arbitrary number of shortcodes.

So I wrote my first WordPress plugin

Here’s a description of it:

This plugin allows you to write your page content like this: “Contact our company, [company_name], by email at: [email].”

Text with these shortcodes can be defined on any number of pages throughout your site.

The values of all of the shortcodes are controlled in a single location: the Custom Fields of your blog’s home page. For the above example, there would be Custom Fields on the home page called “company_name” and “email” with the values, respectively, of “Example Company Name” and “info@example.com”.

This plugin requires that you have WordPress set to show a static Page on the home page under Settings->Reading and “Front page”.

So then, for all the custom fields entered on the home page, this plugin looks for shortcodes (in all pages) and replaces each of their values, upon output, with the relevant custom field value.

This is useful for if you want to fill many pages with text that includes an arbitrary number of shortcodes or template text and have all the values can be replaced in one place.

You can download it from the plugin page, or just grab the SVN.

Random WordPress notes:

  • I highly recommend always installing WordPress by svn – it’s easy (faster than uploading) and makes updates a breeze.  If you want to get fancy, you can also install your plugins by svn through svn:externals.
  • If you want to make the process go really quickly, take a look at wp-create.sh.  I’m using this (plus other tools) to setup WordPress installations in no time.
  • I just found out about /wp-admin/options.php for the first time – very handy way to see/edit all saved options at once.
  • I also just registered for WordCamp 2009 in San Francisco… looking forward to it!

Follow @philfreo on Twitter

Want to know when I write another post? (very infrequent)


  1. Jason said,

    May 11, 2009 @ 12:37 am

    Congrats bro! Great work… this is a great idea for a WordPress plugin.

  2. Technologies I’ve worked with in 2009 | Phil Freo - Website Design, Development, & Blog - Jacksonville/Gainesville, FL said,

    January 17, 2010 @ 8:00 pm

    […] a WordPress plugin to make deploying multiple sites easier, along with plenty of other WordPress […]

RSS feed for comments on this post