Are you looking for a way to create a shortcode that embeds a Google Trends graph in posts and pages? This Google Trends shortcode will embed a graph of any comma separated query you enter to display a trend over time.
- Add this code to your theme’s functions.php file or in a site-specific plugin.
- Be sure to add a
+sign between multiple words that are part of a single query.
- By default, the geolocation is set to the United States, so be sure to change the
geoattribute if you need it to be set to another location.
- Here is an example shortcode:
[trends h="450" w="500" q="wordpress,+wordpress+theme,+wordpress+plugin,+wordpress+snippets" geo="US"]
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: 9 Best SEO Tools to Grow Your Website Traffic, FAST!
Comments Leave a Reply
Can you update this to work with Trends update?
I’ve been trying, but it is annoying.
Also so that you can use it twice on one wp post/page, which seems to be a problem.
Hello Debjit, thank you for the tutorial. It really helps!
However, is there any way to only providing trends statistic for the past 5 years?
Any help would be appreciated!
How could I dynamic a organogram chart for a organisation…
Could you please provide more details about what you are trying to do?
[…] Source: http://wpsnipp.com/index.php/functions-php/shortcode-embed-google-trends-graph… […]
[…] to Kevin Chard for the […]