Using SSI with WordPress

March 8, 2009 by  

Server Side Includes (SSI) are a very powerful tool that can be used to update multiple pages on a site quickly and with minimum fuss.

e.g. Imagine you had a site and you wanted to include a list of recommended merchants at the bottom of every page.  What happens if one of the merchants changes their affiliate link, or drops you as an affiliate, or simply does not convert?  If you site had 100 pages, you would have to manually update 100 pages and re-upload all 100 pages. 

With SSI, you would have this list of merchants in a single text file.  You would then “include” that text file in all of the pages on your site.

If you need to change a link, you simply change the link in the text file and re-upload that one file.  The merchant list will then be updated on every single page of your site.

Typically I’ll have 4 or 5 of these “merchant files” for any site I build.  The list of merchants and ads shown in these files will be geared towards the section on my site in which they will appear.  e.g. on a contact lens site, I would probably have one merchant file for the pages advertising prescription lenses, and another merchant file for cosmetic lenses (those lenses that are just for appearance).  I might even have a separate file for “halloween lenses”, and include photos of vampire eyes, or cats eyes – whatever is hot at the moment.

By keeping my merchant lists to a few separate files, I can quickly and easily swap out merchants, add in new promotions (e.g. at Halloween there are always special offers, and these can be added to all “Halloween” related pages in a few seconds) and have total control over what ads are showing on the various sections of my website.  If changes need to be made, I don’t need to edit every page on my site, just my include files.

Do you see the power of this?

To help with SSI in WordPress sites, there is a plugin I recommend.  I have it working on a WordPress 2.7.1. installation so can confirm it is compatible with this version of WordPress.

WordPress Plugin: Include It

Download and install it.

Now, in an HTML editor (or text editor if you prefer), create the file that you want included in your pages.   Construct it in standard HTML.  It can include a table, headers, affiliate links, text, images etc.  When you have finished the include file, save it to the root folder of your site.  You can give it any name you want, e.g. merchants.txt, merchants.html etc.

Now, with the plugin active, simply add the following code in the position of your WordPress post that you want the merchant list to appear:

[include file=merchant.txt]

Save your post, and you are finished.

The contents of the merchant.txt file should display in the post.

Add this line to every post you want the list to appear in.  When you need to change the merchant list, simply edit the merchant.txt file, and upload it.  The merchant list will be updated on every page that you added it to.

Do you have any other uses of SSI that you think readers of this blog would be interested in?  Please feel free to leave comments on this article below.  You do not need to register to leave a comment.

Print This Post Print This Post

Related Articles

  • WordPress Template Hierarchy - WordPress template system is confusing for those new to WordPress. There is a simple hierarchy of templates that explains why some templates have certain files, while others do not. Bookmark on DeliciousDigg this postRecommend on FacebookBuzz it upshare via RedditShare with StumblersTweet about itBuzz it upSubscribe to the comments on this post
  • Creating Custom sidebars in WordPress - Have you ever wanted to have certain ads only show if the sidebar of certain pages? WordPress uses a template system that means every page uses the same sidebar, but we can add code to the sidebar to test if a page is in a certain category and then insert code if it
  • Manual Upgrade of WordPress - It has happened a few times to me.  The automatic upgrade plugin for WordPress hasn’t worked.  The last time this happened was with WordPress release 2.6.1. and it happened on all of my blogs.  Is it a hosting issue, or a plugin issue?  I am not sure, but what I am sure about is that
  • Adding Video to your WordPress Blog posts - There are a few plugins that can help with adding video to your blog posts, and I’ll show you one of these in a future tutorial, because for most popular video sites, adding video is as simple as grabbing the embed code and pasting it into your WordPress post. Let’s look at an example: If you find
  • WordPress 2.7 Preview - Since I am using WordPress almost exclusively for building my own affiliate sites, I decided to join the WordPress 2.7. beta testers so I could give you a quick overview of what is coming.  What I cover here is only a small part of WordPress 2.7., and represents what I found interesting in the hour
"The Money Is In The List"

AWeber proves it to thousands of businesses every day.

Learn how email marketing software
can get you more sales, too.

Comments

7 Responses to “Using SSI with WordPress”
  1. frank says:

    This seems like a great tool. However, Every blog I have worked with, has a footer.php file. You can do the same by imputing the text/links in the footer.php file. Also if you want to do the include in posts, you can just put the code in the html of the post, without using the plug-in. No?

  2. Andy says:

    Hi Frank
    I think you are kind of missing the point here. If oyu put code in the footer, it apears on every page of your site – maybe not something you want. Also using the templates like that restricts where on the page you can include the code.

    As for including the html in the post, that is covered in the beginning of my post. If you insert that code into 100 pages on your site, then changing that code would mean manually editing 100 pages.

  3. Cici says:

    This plugin seems designed for inclusion in the posts or pages.
    I`m trying to accomplish a SSI function to be included in the sidebar and it doesn`t seem to work there.

    My objective was to create one include file that can be used for several `blogettes` that will be added to an existing html style site.
    I want to integrate the navigation so it all flows, and when new `BLOGETTES`are added, the navigation can be easily updated by changing the one include file.

    Any ideas on how this can be accomplished?

  4. Bjarne says:

    As it did not work in side bars, I found something better (at least for PHP freaks). Try “Executable PHP widget”, which is like the Text widget, but it will take PHP code as well. Allowing PHP, you may include files or even build anything else in PHP. I used it for switching banners randomly.

  5. Suni says:

    How do I make it work with text widgets?

Trackbacks

Check out what others are saying about this post...
  1. [...] 3. Include It – This plugin is very cool.  When I use to build static HTML sites I used server side includes very heavily.  This plugin replicates that functionality.  I wrote an article on using this plugin called Using SSI with WordPress. [...]



Leave A Comment...