Create a PDF viewer shortcode

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 Google Docs. The following recipe will show you how you can do that.

The first step is to paste the following code into your functions.php file:

function pdflink($attr, $content) {
	return '<a href="' . $attr['href'] . '">'.$content.'</a>';
add_shortcode('pdf', 'pdflink');

Once you saved the file, you’ll be able to use the shortcode on your posts and page. Here is the syntax:

[pdf href=""]View PDF[/pdf]

If you enjoyed this article, please consider sharing it!


  1. viagra pillen 9 years ago

    Awesome blog over here! Thanks for sharing this very usefull information. I will visit your blog again into a couple off days to check if you have some new articles.

  2. Stefah 9 years ago

    You can certainly see your expertise in the paintings you write. The world hopes for even more passionate writers such as you who are not afraid to say how they believe. Always go after your heart.

    • Marni 9 years ago

      This is ecxatly what I was looking for. Thanks for writing!

  3. Sivalia 9 years ago

    I like this usefull information, for that reason I wanna thank you for posting it and I’ll follow your blog even more when you’ll keep up the good work!

  4. Shreves 9 years ago

    Just wish to say your article is as amazing. The clarity on your publish is simply nice and that i can suppose you are a professional on this subject. Well together with your permission let me to snatch your RSS feed to keep updated with approaching post. Thank you a million and please carry on the gratifying work.

    • Lakesha 9 years ago

      I really wish there were more artciels like this on the web.

  5. viga 9 years ago

    good day I just read your article and I wanna thank you for the awesome information in it! Please keep up the good work guys!

    • Hawk 9 years ago

      At last! Someone who unedrstands! Thanks for posting!

  6. Micle 9 years ago

    Great website. A lot of useful information here. I am sending it to several pals ans also sharing in delicious. And of course, thanks on your effort!

  7. Dunsmoor 9 years ago

    Whats up very nice site!! Man .. Excellent .. Wonderful .. I’ll bookmark your blog and take the feeds also?I am happy to seek out numerous useful info here within the put up, we want develop more strategies in this regard, thanks for sharing. . . . . .

  8. Berna Kilger 9 years ago

    Have you ever thought about including somewhat bit extra than just your ideas? I imply, what you say is important and everything. However its obtained no punch, no pop! Maybe if you added a pic or two, a video? You could possibly have such a extra highly effective weblog for those who let people SEE what youre speaking about as a substitute of just studying it. Anyway, in my language, there usually are not much good supply like this.

  9. Isabella 9 years ago

    All of these artilces have saved me a lot of headaches.

Leave a reply

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