This took longer than I thought to figure out. I wanted to use a server side include so I can use files on my webserver, but that are not within my WordPress installation. I tried a bunch of stuff, but luckily was able to see the error messages when it failed by viewing the source code of the WordPress blog. For instance, I got “syntax error, unexpected T_STRING”. This is the right code (assuming, of course, that the file you want is on the same server, but just in a directory outside the WordPress installation):

<?php include(ABSPATH . ‘/filename.html’); ?>

ABSPATH means, as you can no doubt imagine, absolute path. So if the file you wanted was in a sub directory such as “myfiles” you’d change the above to:

<?php include(ABSPATH . ‘/myfiles/filename.html’); ?>

You’d typically be calling for a file with an extension such as .html, .htm or .php. I need to do this as I plan to merge a new WordPress blog into an existing site, and the site has CSS style menus driven with an unordered list of links in a separate html file which I only want to have to edit in the one place.

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>