Embed Google books in your posts using shortcode

Adding the first snippet to the functions.php of your wordpress theme will let you use shortcode to embed google books. Just because it took me a while to find the ISBN number to embed a book. Look at the top right of the page when viewing a book for “About This Book”. Click on about this book and at the very bottom of the page you will find the ISBN number.

You will also notice that some books have multiple ISBN numbers eg: 0578022702, 9780578022703 both should work but grab the first one before the comma. If the book does not have an ISBN number you can get the id from the url.

 

add_shortcode('gbooks', 'sc_embed_google_books');
function sc_embed_google_books( $atts ){
extract(shortcode_atts(array(
"id" => '',
"width"  => '600',
"height" => '900',
), $atts));
return '<script type="text/javascript" src="http://books.google.com/books/previewlib.js"></script>
<script type="text/javascript">
GBS_insertEmbeddedViewer("'.$id.'", '.$width.','.$height.');
</script>';
}

 

[gbooks id="0578022702" width="400" height="400"]

Leave a comment