Latest Updates » [1] Auto XML Sitemap [2] Create Contact Page [3] Blogger and Wordpress Templates! Download Now !


Tuesday, 2 July 2013

WPSNIPPET:How to embed Gtrends graph in posts



Google Trends is a service that launched in May 2006 that allows you to see how popular search terms have been over time on Google.Google trends map that displays how often specific keywords, subjects and phrases have been searched for on Google over a time.

This is best free Google service that provides charts that show how often words, phrases and topics have been searched for over time. Now if you want to embed this Google trends graph into your WordPress blog then this wp snippet can help you. How to do this just read on..


 How to embed Google trends graph into WordPress Pages and Posts..



Step 1. You need to create a short code for wordpress blog. Open your functions.php file and paste following code at end of file..

function wps_trend($atts){ extract( shortcode_atts( array( 'w' => '500', // width 'h' => '330', // height 'q' => '', // query 'geo' => 'US', // geolocation ), $atts ) ); //format input $h=(int)$h; $w=(int)$w; $q=esc_attr($q); $geo=esc_attr($geo); ob_start(); ?> <script type="text/javascript" src="http://www.google.com/trends/embed.js?hl=en-US&q=<?php echo $q;?>&geo=<?php echo $geo;?>&cmpt=q&content=1&cid=TIMESERIES_GRAPH_0&export=5&w=<?php echo $w;?>&h=<?php echo $h;?>"></script> <?php return ob_get_clean(); } add_shortcode("trends","wps_trend");

Step 2. Save your functions.php file.

Step 3. Now use following short code into your blog pages or posts...

[trends h="450" w="500" q="wpsnipp,wordpress,+wordpress+theme,+wordpress+plugin,+wordpress+snippets" geo="US"]

If you enjoyed this article pl consider it sharing with friends.. Thanks to K Chard for this coding.


Kindly Bookmark this Post using your favorite Bookmarking service:
Technorati Digg This Stumble Stumble Facebook Twitter

Advertise Here

0 comments:

Post a Comment


ABOUT THE AUTHOR

Hi! I am K Ajay, currently live in Chandigarh, India. A young Web Designer, Pro Blogger, Graphic Designer & an addicted Web Developer. I love working on Blogger and WordPress using CSS Tricks,and Web Designing. Read More...

FOLLOW US HERE


RANDOM POSTS

Bwidgets4all-Helping Bloggers with Blogging Tricks © 2013. All Rights Reserved | Free Blogger Templates | | Back to Top