Mobile-Menu iFuturz Infoweb Inc. Contact Portfolio

07

Aug

Create a PDF viewer short code in wordpress

Create a PDF viewer short code in wordpress

Posted On : August 7, 2013

| 2 Comments

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:

1
2
3
4
function pdflink($attr, $content) {
	return '<a class="pdf" href="http://docs.google.com/viewer?url=' . $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 at your backend. Here is the syntax:

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

Here in given below figure, “View PDF” link is displaying which was added at wordpress backend post by using above code.When clicking on “View PDF”, you will be able to see a pdf file in google doc.

  • Tags:

Comment

Posts

  • We’re a group of volunteers and opening a brand new scheme in our community.
    Your website offered us with valuable information to work on. You have done a formidable task and our whole neighborhood shall be thankful to you.

    Bert

    • Its an honor helping you guys. Do let us know if we could be of further assistance

      iFuturz