Embed Google Books in Your Posts Using Shortcode

Embed google books

Many learners want to collect book from Google books. So you can embed Google books in your posts using shortcode in your WordPress site very easily. Especially some clients give task to their web developer to display Book from Google book. You can display this Google book by using WordPress plugin. But some clients want to avoid using plugin. Here we will use some PHP codes in our functions.php file which will let you use shortcode to embed Google books in your WordPress post content.

Please add the following codes below in your themes functions.php file

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

Embed Google books in your posts using shortcode

Now we will add the below shortcode with our content where Google books will be displayed.

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

Here our Google book id="1234521452"

This Google Books Id you will find from Google books ISBN.

Learn more about WordPress Shortcode

About Admin

Hi I am Md. Masum Billah Contributor of this website. I always like to share various things with other. In this website I am sharing web design related tips and tricks, necessary web development tools, source codes for beginner and advance web developer. You may join with us to help other who want to learn web design and development. Thank you for stay with.

Leave a Reply

Your email address will not be published. Required fields are marked *