Create WordPress Shortcode To View PDFs

PDF

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

Advertise here 50% Off

Comment