WpCode.net

Daily Wordpress Code Snippet

How to embedd Google Book using shortcodes

| 0 comments

Pin It

This code is usefull if you need to embed a Google Books Preview in your posts or pages using shortcode, when writing your content add the shortcode [gbooks id=""] with the id of the book and will be appended in a frame large 600 and tall 900 px. Continue reading

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>';
}

Leave a Reply

Required fields are marked *.

*