Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to use wordpress post data (eg title, link, custom fields) as a data source for google visualisations.

I want to be able to take the wordpress data for all posts and visualise using the "table" and "motion" charts.

Related doc http://code.google.com/apis/chart/interactive/docs/gallery/table.html

http://code.google.com/apis/chart/interactive/docs/gallery/motion.HTML

How do I loop though all my posts to create an array that that will work as a data source? I want to get post titles, post urls and associated custom fields for graphing.

Hope you can help!

share|improve this question

1 Answer 1

Well you can just use the WordPress loop with a custom query to throw all the data you need into arrays.

For example if you want all the post titles in an array (using get_posts);

$all_posts = get_posts('numberposts=-1');
$all_titles = array();
 foreach( $all_posts as $all_post ) {
  $all_titles[] = $all_post->post_title;
 }

As for using the data in Google charts that is up to you, but I would recommend using JSON ( using json_encode), XML or one of the many PHP chart wrappers.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.