Shortcode to display external files on your posts

Open your functions.php file and paste the following function in it:

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' );

Once done, you can use the shortcode. It’s pretty simple:

[show_file file="http://www.test.com/test.html"]

Thanks to Vladimir Prelovac for the handy tip!

Leave a Reply

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