Wordpress Tutorials, Plugins & Themes

How To: display external files in your WordPress posts?



I learnt this trick a few days ago, its possible to embedĀ  your images, text files into your wordpress blog posts. WordPress short code API is a easiest way to to add external files in your wordpress posts.

First open your theme “functions.php” and put the following code snippet:

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

After that, you can write somthing like that in your post:

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

[Special thanks: Vladimir Prelovac]

Be Sociable, Share!

    Author: Ahmed Iqbal

    I'm really big fan of Wordpress, I'm also editor of Wp-Edge.com, I've spent 5 year's for developing PHP based websites and Blogs.But i prefer Wordpress and Codeigniter Framework. You can find me on Google Plus

    Leave a Reply

    Required fields are marked *.

    * Copy This Password *

    * Type Or Paste Password Here *