How to include text from a single source on websites
Sometimes you need to keep a master copy of some text on a website that just updates. For example, if you have a group of terms and conditions across multiple sites then it would be easier to update once rather than on each site.
I needed a solution as Bet365 are always updating their terms and need me to keep them up to date. They provide an auto-updated iframe of the terms in the backend. It works fine in the main body of a post but in the sidebar, it doesn't show. So I needed to find another way.
I ended up using the code on this site
/* Add shortcode to include external content */
function show_file_func( $atts ) {
extract( shortcode_atts( array(
'file' => ''
), $atts ) );
if ($file!='')
return @file_get_contents($file);
}
add_shortcode( 'show_file', 'show_file_func' );
Add that to functions.php in the theme files. Ideally, you'd have a child theme and put in there.
to use just add this.
[show_file file=”YOUR-URL.com/page.html”]
I actually use a plugin called shortcoder, it allows me to update shortcodes on the site quickly. Very useful for banner management. So I can paste the code into the terms shortcode I have already set up. I was all very simple in the end.
There may well be a plugin that does allow you to reference external text in a more user-friendly way but I couldn't find it. The RPS include plugin referenced here only works within a site, not externally. Would be handy to have like a CDN for text snippets but I can't find one either. I use cloudinary.com for some banner management but there appears to be nothing for txt. Maybe because text is so simple, there's not much demand for a solution.
Ben Luong is a technical marketing consultant who operates where AI falls short. In a world flooded with cheap, mediocre code and automated strategies, he provides the expert integration, verification, and strategic accountability required to make modern marketing stacks profitable. He specialises in architecting Google Ads, SEO, and GA4 into a single, high-performance system that is accountable to the bottom line.


