Improved Include Page Plugin for WordPress

Improved Include Page

Improved Include Page (IIP) allows you to use a shortcode to include the content of any page inside any other page or post. This makes it easier to manage content that needs to be published in multiple pages.

You can download this plugin from the WordPress plugin repository.

Plugin Features Include

  • Page title can be displayed with optional HTML code.
  • Content can be displayed with different styles (full, teaser, custom ‘more' link).
  • WordPress filters are applied to both the content and the title.
  • Supports the WordPress Shortcode API.


The current version supports the following parameters:

  • displayTitle (boolean) toggle title display
  • titleBefore/titleAfter (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' link
    • DT_FULL_CONTENT – Full content including teaser
    • DT_FULL_CONTENT_NOTEASER – Full content without teaser
  • more (string) text to display for the ‘more' link


Example 1: using Shortcode API in posts or pages
You can include a page's content in a page/post using the syntax:

[include-page id=”123″]


[include-page id=”3″ displayTitle=”true” displayStyle=”DT_TEASER_MORE” titleBefore=”<h3>” titleAfter=”</h3>” more=”continue»”]

Example 2: basic usage in templates
If you wish to include the content of page number ‘4' insert the following code into your template file (e.g. sidebar.php):


<?php echo iinclude_page(4, null, true); ?>

In order to avoid PHP errors if the plugin is disabled, you should use the function with the following syntax:

<?php if( function_exists( ‘iinclude_page' ) ) iinclude_page( 4 ); ?>

Example 3: using optional parameters in templates

You can also display the page title using the following code:

<?php iinclude_page( 4, ‘displayTitle=true&titleBefore=<h2 class=”sidebar-header”>' ); ?>

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 4.50 out of 5)


  1. Hello

    I have a strange 503 error on my site that comes not all the time, that I am investigating. It has escalated the last 2 weeks.

    I have used your plugin a long time and is very fond of it.
    We include pages that include pages and that has always worked fine.

    I get this in the logs
    [04-Mar-2018 15:05:35 UTC] PHP Notice: Trying to get property of non-object in /customers/f/7/5/ on line 294
    [04-Mar-2018 15:05:35 UTC] PHP Notice: Trying to get property of non-object in /customers/f/7/5/ on line 294

    Could this have something to do with my 503 errors?


    • Your logs will pick up notices, warnings, and errors from PHP. Notices and warnings won't, as far as I know, cause 503 errors.

      If I had to guess, I'd say your site is being repeatedly accessed by someone/something and it's running out of memory. Check your access logs for repeated requests and also your server's memory to see if it is being used 100%.

  2. Marios,

    Not sure a better way to pass the along, but my expectation was that the URL entered as ID would work with relative paths as well, but it seems that it doesn't I modified the code to allow for that (See code at end of post). The use case is we have documentation that repeats pages for each software version, and each set of pages updates over time without effecting previous versions. Using a relative URL allows us to copy and update without updating each include in the new copies. Note I did not explicitly handle "~/path/more/" for defining from the root as "/path/more/" means the same thing and is already how your plugin worked, as well as "./path/more/" which is the equivalent of "path/more/" isn't explicitly handled.

    Usage example:

    Current location of post we are adding the short code in:

    1. From Root [include-page id="/snippets/example-include-post/"] will look for a page at:

    2. Add to Current Position (Relative) [include-page id="snippets/example-include-post/"] will look for a page at:

    3. Go up in the tree (Relative) [include-page id="../../snippets/example-include-post/"] will look for a page at:

    Modified code, if you want to update to include in your plugin:

    static function get_page($post_id, $type, $status, $tempPost) {

    if (is_numeric($post_id)) {
    $_page = get_page($post_id);
    } elseif( is_string($post_id) && function_exists('get_page_by_path')) {


    //split string by slash for easy comparison
    $postURL_arr = split('/', $post_id);

    //if the url starts with a slash we start at root so no modification needed
    if($postURL_arr[0] == "") {
    $_page = get_page_by_path($post_id);

    //else check if we need to go down a level from where we are
    } elseif ($postURL_arr[0] == "..") {
    //we need the URL of the current post/page
    $tempPostURL = rtrim(parse_url(get_permalink($tempPost), PHP_URL_PATH), '/');
    $tempPostURL_arr = split('/', $tempPostURL);
    $newPost_id = "";

    //see how many levels to go down, we will ignore .. that are not at the beginning (not valid)
    foreach( $postURL_arr as $value ){
    if( $value == '..' ){
    //remove from end of current path
    } else {
    //build the include url without ../
    $newPost_id .= $value . "/";

    //turn the altered array back to a string
    $tempPostURL = implode("/", $tempPostURL_arr);

    //combine the updated current path with the include path
    $newPost_id = $tempPostURL . "/" . $newPost_id;

    //get the page contents per existing plugin
    $_page = get_page_by_path($newPost_id);

    //else we are adding relative to the current page (child of current page)
    } else {
    //get current path
    $tempPostURL = parse_url(get_permalink($tempPost), PHP_URL_PATH);

    //combine path
    $newPost_id = $tempPostURL . $post_id;

    //get the page contents per existing plugin
    $_page = get_page_by_path($newPost_id);

    //END MODIFIED CODE (original line below)

    //$_page = get_page_by_path($post_id);
    } else {
    return false;
    } // end if

  3. Is there any known-bug using it with MAMP:Version 4.2.1 (852)?
    I can not make it work locally :( as I was a frequent user before. And it seems to be working on my site.

    • There is no known bug, but I also haven't tested it with MAMP.

  4. I added this pluggin last week and its was working great. I have updated my theme and it has stopped working, the short code I used is: [include-page id="dell caddies"][/include-page]. Any idea's?

    • Sorry, but I have no idea why it would work in one theme and not another.

    • OK all sorted now, somebody changed the menu slightly!

  5. Hello Marios,

    The improved include page just broke with a Wordpress update. I'm getting this error message:

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'ec3_filter_the_content' not found or invalid function name in /home/fiddlers/public_html/wp-includes/class-wp-hook.php on line 298

    Any tips on what code I need to change to get it to work?

    • From the error message which references 'ec3_filter_the_content' it looks like the issue is with the Event Calendar plugin. Are you using that plugin?

      • Yes, I am. It's the main reason for using the include plugin.

        • I commented this line and that seems to have brought back the functionality again

          // Uncomment the following line below if you are using EventCalendar plugin
          // add_filter('the_content', 'ec3_filter_the_content', 20);

        • Thanks for the update. I totally forgot about that code. I'm glad you dug in and didn't give up.

  6. hi , the plugin is brilliant , but i have a problem when i use it ,
    it is working when inlcude file is in page (example id="117")
    but it is not working if the install file is at post (example id="118")

    both i use the code below, just the id different
    [include-page id="117"] [include-page id="118"]

    thank again for the great job


    • The plugin includes pages only. You can include a page into a post, but you can't include a post into something else.

      • thank a lot !

  7. The plug-in stopped working this morning. My client posted a new page and a new event and the shortcode is no longer pulling in the include. I've since deleted the new page and the new event, but still nothing :(

    • What else was done? Was WordPress upgraded? Were other plugins installed? Something had to happen to cause the plugin to stop working.

      • Yeah, I've just looked at version numbers and the EventsCalendar plugin was updated to 4.1.4 yesterday and it looks like my client has autoupdates turned on. The individual events are still pulling in the content perfectly, it's just list view that's no longer pullling in the content.

        Events that contain their own text do show up content and featured image in list view, it's the ones with includes that are not and they make up the majority of the events.

        • First, auto-updates are bad (in my opinion) :-)

          Second, if your need is critical, you could try going back to an older version of the Events Calendar. Older versions are here: I can't guarantee this will work as every plugin is different.

          Third, I'm going to install the latest Events Calendar to see if any errors that show up. I'll let you know if I find anything.

        • I've installed the Events Calendar plugin. I created an event and I included a page. When I view the event I see the included content.

          When I go here /events/list/ I see the event, but without the included content. Is that the problem?

          I also tried a few older versions of the plugin and the included content didn't show on the list view. What was the last version of the plugin where this functionality worked as you described?

        • I'll switch off auto updates.

          When I go here /events/list/ I see the event, but without the included content. Is that the problem?

          Yes, exactly that.

          I also tried a few older versions of the plugin and the included content didn't show on the list view. What was the last version of the plugin where this functionality worked as you described?

          As autoupdate is running, it must've been 4.1.3 we were using before. I know it was fine until two days ago. it was seven days ago that I did all the work to get your plug-in to work with excerpts. Weird that you can't get older versions to show content in list view. It's not mission critical - my client is okay with just the links and dates. I do have a backup of everything, but restoring that seems a bit like a sledgehammer to crack a nut.

          Thank you for your input and for the link to the previous versions

  8. Hi,

    This is a superb plug-in for a client of mine who runs a bistro and an events calendar. I've uncommented the two lines you had so thoughtfully included for users running the EventCalendar plug-in and it works really well. However it doesn't work in the Excerpt field for posts in the EventCalendar. Is there a way of implementing this that you know of?

    Many thanks.

    • That isn't something I've considered. Off-hand I'm not sure what it would take.

      • Okay. Thanks for the quick response. I've googled and come up with this: add_filter( 'the_excerpt', 'do_shortcode');
        But it doesn't work. I'll keep looking but I'm quickly getting beyond my skills!

        • I've just found a page that says shortcode is disabled in the excerpts field of the Events Calendar on purpose.

          I'm now officially out my depth! Thing is, if your shortcode plug-in works only in body text for events and not in the excerpts field, I'll have to go back to doing them all manually again. That kind of defeats the purpose of the shortcode plug-in. My client isn't happy to have no text displayed where the excerpt would show.

        • I did it! I changed the 'false' to 'true' in this line of code and it worked! (line 1338 in src/functions/template-tags/general.php)

          $allow_shortcode = apply_filters( 'tribe_events_excerpt_allow_shortcode', false );

        • Well done!

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail.