wordpress snippets last updated   : July 14, 2014
we now have 634 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 →
  • 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?

jqsnipp.com | we just launched jquery snippets website