Include Me is a powerful plugin that lets you to include in any post or page and external HTML or PHP file or the content of another post/page. When you include a PHP files, they will be executed and their output included, so you can develop independent scripts that can be made available on posts or pages.
An example? You want to publish a report generated by some queries on a database. Just develop such script and make it to output an HTML fragment. Then include it on a page with Include Me.
Where is the advantage over developing a theme custom page? Let me answer with another question: what happens to theme custom pages when you change theme?
Download and Support
Include Me syntax
In any post or page you can use Include Me with the shortcode:
where the “file” attribute contains the filename to be included. Any textual file can be included and if it is a PHP file (with “.php” extension) it will be executed and its output included.
The filename can be relative (not starting with “/”) so it will be searched starting from the blog root folder (for technicians, ABSPATH will be added at the beginning). If the filename is absolute (starting with “/”) it will be used as is (so you can include files even external of the site root folder).
Including another post content
It’s a rather particular case but you may need to include another post content in a series of other posts or pages just to have a single change point. In this case the syntax is:
[includeme post_id="a post id"]
The “post id” is the nmeric identifier of a post.
Generating an iframe
A second syntax is available and generate an iframe instead to include the file. The iframe syntax is:
where “url” is a common web address. Any other attribute added to the short tag will be used as an iframe attribute. For example if you write:
[includeme src="http://www.example.com" frameborder="0" width="500" height="400"]
the result will be
<iframe src=”http://www.example.com” frameborder=”0″ width=”500″ height=”400″></iframe>
Nice, isn’t it?
I widely used this plugin (and its old and incompatible version Include It) on my blogs.
If you include a PHP script, it can access the shortcode attributes using the syntax $attrs[‘attribute name’]. For example calling:
[includeme file="out.php" value="My name is Stefano"]
and with out.php
<?php echo $attrs['value']; ?>
The output will be, of course “My name is Stefano”. So you can create a generic script and make it doing different things using the shortcode attributes.