How To Create a PDF viewer shortcode in WordPress


Sponsored Links




WordPress PDF Shortcode use google docsDid you know, we can create PDF viewer shorcode in WordPress with easy steps? All need to do only using Google Docs viewer tools and integrated it into our WordPress site. The first thing we should do, is written shortcode function in our functions.php theme files.

Simple Method PDF Shortcode functions

function pdflink($attr, $content) {
	if ($attr['href']) {
		return '<a class="pdf" href="http://docs.google.com/viewer?url=' . $attr['href'] . '">'.$content.'</a>';
	} else {
		$src = str_replace("=", "", $attr[0]);
		return '<a class="pdf" href="http://docs.google.com/viewer?url=' . $src . '">'.$content.'</a>';
	}
}
add_shortcode('pdf', 'pdflink');

And done, how to use PDF Shortcode? it’s simple just write down this tiny code on your content

[pdf href="http://yoursite.com/linktoyour/file.pdf"View PDF[/pdf]

Thanks for NoScope for this great tips and we hope you can do it on your own WordPress site

Subscribe to Full RSS Feed

RSS FeedIf you thing this article useful, please consider subscribing to our RSS Feed or e-mail updates and stay updated with us. You can also follow @WPTricksNet on twitter for latest updates.

About WP Tricks

We are WordPress Family, we collected and writed useful tips and tricks for you WordPress. We share it for you...

Related Tips and Trick from Local Data and on The Net

WordPress tip: Create a PDF viewer shortcode

Daily recipes to cook with WordPress If you’re using PDF files on your WordPress blog, it could be very cool to give your users the chance to open them using Read More

How To Create a PDF viewer shortcode in WordPress / WordPress

Did you know, we can create PDF viewer shorcode in WordPress with easy steps? All need to do only using Google Docs viewer tools and integrated it into our WordPress Read More

WordPress › pdf « Tags « WordPress Plugins

catalog of PDF files in your wordpress posts/pages using a shortcode. web page using the Google Docs Viewer (no Flash or PDF A plugin to create PDF files of articles Read More

Useful WordPress Shortcodes Resources - Web Design Blog, Web

WordPress tip: Create a PDF viewer shortcode; WordPress tip: Create a Tweetmeme “Retweeet” shortcode; WordPress shortcode: Display the loop; WordPress shortcode Read More

Creating a Simple Button Shortcode in WordPress

Shortcode is the hottest trending topic in WordPress. See how to create a simple button shortcode within Simple PDF viewer for WordPress blog; Creating Multiple Widget Read More


7 Responses to How To Create a PDF viewer shortcode in WordPress

  1. Irina says:

    Hello

    Do you happen to know if you can remove the print and download links from the viewer?

    Thanks

  2. Hey thanks, great tips! Never thought about using Google Docs as a direct document viewer. Guess it makes sense. I’ll be sure to use it in a future project!

  3. Pingback: wp-popular.com » Blog Archive » How To Create a PDF viewer shortcode in WordPress # WordPress Tricks & Tips

  4. artamart says:

    great tips, thanks for sharing
    is this violate google TOS ?

  5. Nathan says:

    The only problem with this is, if the person viewing your website is not signed in to google – they will not see your pdf docs.

    Does anybody know a workaround for this problem?

    • WP Tricks says:

      I will re write this trick with another way, I hope will fix this problem..

    • Anays says:

      yes this is awesome and i will be incorporating this in my education blog. Although Nathan is right, it would be ideal for all to see. awesome, im still going to do it as my students have gmail, and most of their work is on a private level.
      Thanks,
      Anays

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>