Shortcode to embed google trends graph in posts and pages

WooCommerce setup - multiple regions for shipping zone

This Google trends shortcode will embed a graph of any comma separated query you enter to display a trend over time. Make sure to add a + between multiple words that are part of a single query. By default the geolocation is set to United States so change geo praram for another location.

function wps_trend($atts){
        extract( shortcode_atts( array(
                'w' => '500',           // width
                'h' => '330',           // height
                'q' => '',              // query
                'geo' => 'US',          // geolocation
        ), $atts ) );

        //format input
<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>
return ob_get_clean();
[trends h="450" w="500" q="wpsnipp,wordpress,+wordpress+theme,+wordpress+plugin,+wordpress+snippets" geo="US"]

Comments  Leave a Reply

  1. disqus_guEqGGv6i5 September 30, 2014 at 7:10 am


  2. How could I dynamic a organogram chart for a organisation…

    1. Could you please provide more details about what you are trying to do?

  3. Best WordPress snippets, hacks and tips from 2013 | CatsWhoCode.com December 30, 2013 at 11:00 am
  4. WordPress shortcode to embed Google trends graphs June 24, 2013 at 11:46 am

    […] to Kevin Chard for the […]

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!