Improved Include Page
Last update: 7th july 2008 (v 0.4.5)
Improved Include Page is a Wordpress plugin which allows to include the content of a static page in a template file with several options. It is an expanded version of the original Include Page developed by Brent Loertscher and it was developed to add some features I needed to build this site.
Key Features
- page title display with optional HTML code,
- content display with different styles (full, teaser, custom ‘more’ link),
- Wordpress filters applied to both the content and the title.
- supports Wordpress 2.5.x Shortcode API
Version Notes (0.4.5)
- Page ID can be a valid page path (WP 2.1 or higher required)
Version notes (0.4.4)
- Added parameter $return (default = false) to iinclude_page() function
- Added support for WP 2.5.x shortcode API
Version notes (0.4.3)
The code of this version it’s been cleaned and optimized using WordPress API.
Version notes (0.4.2)
This version fixes a bug that triggers an error when used with some content filter: the $page global variable is backed up and then restored before returning.
Version notes (0.4.1)
This version contains a bug fix by Jesse Plank: resolves a compatibility problem with the plugin EventCalendar.
How to install it
- Download Improved Include Page from this site or from WorPress plugin’s repository
- Extract the zipped archive
- Upload the file
iinclude_page.phpto thewp-content/pluginsdirectory of your Wordpress installation - Activate the plugin from your WordPress admin ‘Plugins’ page.
- Include pages in your templates ising
iinclude_pagefunction or in your pages/posts using the shortcode syntax.
How to use it
After installing it, the plugin adds the function iinclude_page:
void iinclude_page(int post_id [,string params, boolean return = false])
The function takes three parameters: the id of the page to include (post_id) and an optional string (params) which contains the display options and an optional boolean (return) tells wether to return the content or display it on screen.
Example 1: basic usage
If you wish to include the content of page number 4 insert the following code into your template file (eg. sidebar.php):
<?php iinclude_page(4); ?>
In order to avoid PHP errors you should use the function with the following syntax:
<?php if(function_exists('iinclude_page')) iinclude_page(4); ?>
Example 2: using optional parameter
You can also display the page title using the following code:
<?php iinclude_page(4,'displayTitle=true&titleBefore=<h2 class="sidebar-header">'); ?>
Example 3: using Shortcode API
You can include a page’s content in a page/post using the syntax:
[include-page id="123"]
or
[include-page id="3" displayTitle="true" displayStyle="DT_TEASER_MORE" titleBefore="<h3>" titleAfter="</h3>" more="continue»"]
Parameters
The current version supports the following parameters:
- displayTitle (boolean)
- toggle title display
- titleBefore/after (string)
- string to display before and after the title
- displayStyle (integer constant)
- one of the following:
DT_TEASER_MORE- Teaser with ‘more’ link (default)DT_TEASER_ONLY-Teaser only, without ‘more’ linkDT_FULL_CONTENT- Full content including teaserDT_FULL_CONTENT_NOTEASER- Full content without teaser
- more (string)
- text to display for the ‘more’ link