Create WordPress Shortcode To View PDFs


If your website has some PDF documents which you would like to display to your visitors then it will be usful to the user if they can open it using Google Docs.

In the article I will explain how you can make you WordPress have a shortcode for PDFs to display using Google Docs.

Why Use Google Docs

Google Docs is a free application from Google which makes it easy to view, edit and share documents through your Google account. Therefore if a user can open up PDFs in Google Docs it will make it very easy for them to save the document and share it with other people on their Google Document lists.

Code To Create Shortcode To Open Google Docs

function google_pdflink($attr, $content) {
	return '<a href="http://docs.google.com/viewer?url=' . $attr['href'] . '">'.$content.'</a>';
add_shortcode('google_pdf', 'google_pdflink');
Back to top ^

Join Paulund

  • Get access to 100s of premium tutorials and downloadable content
  • Members content consists of Premium WordPress plugins, CSS packages, jQuery packages, tutorial demo files and templates for 100s of web development tutorials
  • In-depth development tutorials
  • Priority tutorial requests
  • Priority email development support
  • No ads

Here at Paulund you'll find Web Development tutorials and snippets focusing mainly on PHP, WordPress and CSS. Members will get access to premium tutorials that go into more detail about development with these languages. You will also get access to downloadable premium content based on the tutorial.

Join Paulund

Leave a Reply

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