in WordPress

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="' . $attr['href'] . '">'.$content.'</a>';
add_shortcode('google_pdf', 'google_pdflink');

Subscribe To The Weekly Newsletter

Get weekly updates to your email