Tuesday, January 22, 2013

Shortcode to display external files on Wordpress post

Shortcode to display external files on Wordpress post

While blogging on wordpress, sometimes we may need to include an external file on our post, like text or image etc, into our wordpress posts. Checkout the following a very useful shortcode which embed and display any external files in our wordpress blog posts.


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' );
 
 
Now use the shortcode like the following example

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

No comments:

Post a Comment

I just got my #domain @BigRock. Get upto 25% off with my personalized coupon link Get upto 25% off