WordPress Trick: Create A Google Viewer PDF Shortcode [Update]
Want your PDFs to view through Google Reader? Wrap it in a shortcode like this: Link to a PDF. Drop the following in your functions.php:
function pdflink($attr, $content) {
return ''.$content.'';
}
add_shortcode('pdf', 'pdflink');
[Update]: Here’s an updated shortcode function which allows you to also embed PDFs using this syntax: Link to a PDF. Note how it’s just a tad shorter, and you don’t have to remember the “href” parameter, though you can still use it.
function pdflink($attr, $content) {
if ($attr['href']) {
return ''.$content.'';
} else {
$src = str_replace("=", "", $attr[0]);
return ''.$content.'';
}
}
add_shortcode('pdf', 'pdflink');
Also, here’s an example PDF link using the above code: Link to a PDF.
- Wordpress Trick: Google MP3 Player Shortcode
- WordPress Trick: Create A Google Viewer PDF Shortcode [Update]
- Android Market Finally Shows Updates To Your Apps
- Forcing Scrollbars, 2010 Edition