Home (All Topics) → Technology → Software → Improved Include Page Plugin for WordPress
Table of Contents
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.
The current version supports the following parameters:
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″]
or
[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):
or
<?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”>' ); ?>
Check out these related articles:
When enabled, the plugin is crashing the site with, "There has been a critical error on this website."
I disabled all plugins and the site opens. Then I enabled Improved Include Page v1.2. Crashes.
WordPress 6.4.1
Theme: Virtue - Premium Version: 4.10.13 from https://www.kadencewp.com/
The plugin was discontinued on October 8, 2021. See https://wordpress.org/plugins/improved-include-page/
our host has contacted us saying that the improved include page plugin has security vulnerability and need to update. do you have an update coming soon? Thanks
Sorry, no time to work on it.
Marios, If you don't have time would you object to someone else looking into it and maybe adding some setup parameters that will process the 'private' and 'draft' status?
It can't be that hard :-)
If not - no worries, I am going to attempt to modify it on my site. I'll keep everyone posted.
Sure go ahead.
Here is the security vulnerability entry: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-24845
If you don't have any critical information on your website, I am not sure this is a big issue.
Please correct me if my understanding is incorrect.
Technically this is a vulnerability, but it doesn't seem serious to me. The plugin, by design, imports content into pages. And yes, a registered user could use the plugin also by design. If those two things combined are a security threat to your site, then don't use the plugin :-)
I have used this for awhile but I suspect I have outdated syntax here:
[ic_add_posts post_type='page']
Trying to find out I can just include all pages in a master list. Now I get that plus some weird sample/lorem ipsum type text before the pages show up.
https://www.paulbeard.org/wordpress/ideas-various/
I think you might be confusing my plugin with another. The shortcode you provided isn't one that matches what my plugin uses.
Hi Marios
I've used you plugin with great success on sites... Awesome Job !!!
I'm however getting the following error on a new site I'm working on:
Deprecated: parse_str(): Calling parse_str() without the result argument is deprecated in /usr/www/users/precixqcsw/wp-content/plugins/improved-include-page/iinclude_page.php on line 58
Any ideas ?
This is a warning and not an error. It's indicating the future versions of PHP may not support the current use of parse_str. However, everything should still be working at this time regardless of the warning issued.
Many thanks for the info.
It's a bit odd, as regardless if I use: [include-page id=”terms-and-conditions”] or [include-page id=”4157”] nothing appears.
Could it be a Gutenburg issue ?
It could be Gutenberg, but I don't have much experience with it just yet so I can't say with any certainty. One thing to confirm is the the double quotes you're using are normal and not smart quotes. WordPress sometimes changes things to "help" you.
Spot on the money !!!
Gutenburg changed them to ” and not "
had an error because of parse_string:
Uncaught ArgumentCountError: parse_str() expects exactly 2 arguments, 1 given in wp-content/plugins/improved-include-page/iinclude_page.php:58
----------------------------------------------
since php 8.0 it's second parameter is required, see
https://stackoverflow.com/questions/68475652/parse-str-syntax-errors-after-upgrading-from-php-7-4-to-8-0
--------------------------
changed the call on line 58
parse_str( $params );
to
parse_str( $params, $foo ); // $foo as we dont care about the second parameter but it's required
---------------------------------
quick hack, but works for me.
best regard
Thanks for the tip! Hopefully it'll help others.
Note that the plugin is no longer supported and is no longer listed on WordPress.org. As such, I have no way to distribute fixes such as yours.
This looked like the perfect plugin. I wanted to have a side menu that appeared in the side bar on a desktop but at the bottom of the page on a mobile. Because my menu is not a simple hierarchy I have to code it longhand.
So I created a page called Members Menu (which got saved with a slug name "members-menu") This page consisted of a and lots of relevant s for each menu line.
Then in one of the Members' pages I added [include-page id=”members-menu″] expecting the unordered list to appear but there is nothing!
What am I doing wrong?
Are you sure you've got the right slug? If so, I would expect http://www.giffordgolfclub.com/members-menu/ to load, but it doesn't. Try using the ID number of the page instead as that removes all ambiguity.
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/sockerskolan.se/httpd.www/wp-content/plugins/improved-include-page/iinclude_page.php on line 294
[04-Mar-2018 15:05:35 UTC] PHP Notice: Trying to get property of non-object in /customers/f/7/5/sockerskolan.se/httpd.www/wp-content/plugins/improved-include-page/iinclude_page.php on line 294
Could this have something to do with my 503 errors?
Best
/Cristina
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%.
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: https://example.com/version-2-0/example-folder/example-post-name/
1. From Root [include-page id="/snippets/example-include-post/"] will look for a page at:
https://example.com/global/example-include-post/
2. Add to Current Position (Relative) [include-page id="snippets/example-include-post/"] will look for a page at:
https://example.com/version-2-0/example-folder/example-post-name/global/example-include-post/
3. Go up in the tree (Relative) [include-page id="../../snippets/example-include-post/"] will look for a page at:
https://example.com/version-2-0/snippets/example-include-post/
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')) {
//START MODIFIED CODE
//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
array_pop($tempPostURL_arr);
} 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
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.
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!
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.
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
mango
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 !
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 :(
http://fiddlersmusicbar.com/livemusic/
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: https://wordpress.org/plugins/the-events-calendar/developers/. 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.
[quote]
When I go here /events/list/ I see the event, but without the included content. Is that the problem?
[/quote]
Yes, exactly that.
[quote]
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?
[/quote]
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
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.
https://theeventscalendar.com/function/tribe_events_get_the_excerpt/
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!