Skip to content

Instantly share code, notes, and snippets.

@megantaylor
Created April 22, 2013 22:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save megantaylor/5439023 to your computer and use it in GitHub Desktop.
Save megantaylor/5439023 to your computer and use it in GitHub Desktop.
PDF viewer shortcode for WordPress
The first step is to paste the following code into your functions.php file:
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. Here is the syntax:
[pdf href="http://yoursite.com/linktoyour/file.pdf"]View PDF[/pdf]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment