
Years ago, when I was building old school HTML websites, I would use the PHP Include function to insert one web page into another. This was incredibly useful when you had an element that was common among multiple pages (like a sidebar or a footer) and you didn’t want to have to make updates to every single page on your website when you needed to change a footer link.
I’ve finally found a way to do this using WordPress, and at least for me, it’s a game changer. I am currently working on a WordPress website that requires a callout box on each page. Unfortunately this box will change multiple times a year (with different messages and graphics) so just adding the callout box to each page would be a huge task when an update is needed. The theme I’m using does have a callout box feature but it doesn’t meet the needs of this project so I was stuck trying to find another solution.
Through a bit of research I have found solution that is super simple and easy to implement. All it takes is a lightweight plugin and a simple shortcode.
The first step is installing and activating the Insert Pages plugin, available in the WordPress plugin repository. It’s both free and up-to-date so you don’t have to worry about incompatibility issues with the latest version of WordPress.
Once installed you should see a new option for Insert Pages in the WordPress’ visual editor toolbar.
Click the icon and you will see the standard WordPress Insert Page dialog box, allowing you to simply select any page on your site and click on the Insert Page button.
A shortcode is automatically generated in the form of [insert page=’page-id-or-slug’ display=’content’] and inserted into your page. Wherever this shortcode appears, the external page will appear in its place when the page is viewed in a web browser.
You can also just insert the shortcode manually using the same format. Just insert the shortcode [insert page=’page-id-or-slug’ display=’content’] anywhere on your site and replace ‘page-id-or-slug’ with the appropriate page information.
There is only one thing to be aware of, and it’s pretty much common sense. The plugin won’t allow you to insert a page within itself (insert Page A into Page A), which is a good thing. But be careful not to create an infinite loop that will prevent a page from rendering. If you insert Page A into Page B, but on Page B you have already inserted Page A you will create an infinite loop that will cause – the page will try to load over and over again until the web server runs out of memory. Apparently future versions of the plugin will prevent this from happening, so for the time being, beware!