PDF viewer Google Docs shortcode

Google Docs is easy to read documents in .pdf, .doc or .xls online. Creating a shortcode that will open the PDF in Google Docs instead of forcing download?

Simply paste the code in your functions.php.

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

Here is the syntax for using the shortcode on your posts and page.

[pdf href="http://www.domainname.nl/linktofile/file.pdf"]View PDF[/pdf]

Geef een antwoord

Het e-mailadres wordt niet gepubliceerd.