1

Im trying to create a graph that displays count of post per day and display it on the search result page.

Search Example.

  1. User searches with the search term "football".
  2. The search result page shows a date based line graph such as this: https://www.amcharts.com/demos-v3/date-based-data-v3/ and a list below the graph with all the posts. (the graph uses json)

Im thinking something in the line of getting all post with the specific search term and then group them by date and then convert that to json.

Example: { "date": "2012-08-04", "value": 20 }

Any suggestions on how to approach this?

3
  • What have you tried so far? – Matthew Brown aka Lord Matt Jan 10 at 6:22
  • Well, I have achieved some of it separately. My two main challenges are: 1. Output post count grouped by date. 2. Figure out how to generate the JSON array based on that. I'm a bit concerned about the query's overhead using MySQL - since im querying more than 15-20.000 posts. I will be using Redis for the object cache - but since the query term is arbitrary im uncertain about the impact.I would prefer not to create separate tables/indexes - to keep as much as possible within core WP functionality. – Cavamondo Jan 10 at 9:24
  • What's stopping you doing a SELECT fireld1, field2... FROM table_name WHERE stuff GROUP BY things; getting that as an array and dropping the array into json_encode()? – Matthew Brown aka Lord Matt Jan 11 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.