wordpress snippets last updated   : January 29, 2015
we now have 646 snippets

Display external files in posts using shortcode

wordpress snippet

Adding this snippet to the functions.php of your wordpress theme will allow you to include the content of an external file within your page using shortcode.

snippet :  PHPcopy
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' );
source →
snippet :  SHORTCODEcopy
[show_file file="http://wpsnipp.com/data.html"]
source →

Did you like this post? If so please share it with your friends. Thanks!

  • Rob

    This works great for what i need, unfortunately my site css is overriding the appearance. Can i force the embedded file to retain its CSS properties?