X

Display external files in posts using shortcode

WordPress Security - use a strong password

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.


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

Comments  Leave a Reply

  1. 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?

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!