Home / functions.php / Display external files in posts using shortcode
  • How to Display external files in posts using shortcode


    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.

    wordpress snippet : PHP

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

    wordpress snippet : SHORTCODE

    [show_file file="http://wpsnipp.com/data.html"]

    ( WordPress codex functions, hooks, in this snippet. )

    add_shortcode, shortcode_atts, wp,
  • 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?