0

Here is what i want to do: For a specific date i want the number of posts from a certain tag.

For example: on 14th March i have a certain number of posts tagged "jazz". I want to plot that number on y-axis of a chart (dont worry about how i make the chart, i just want to get the number) and the corresponding date on x-axis. Hence showing a graph of posts tagged 'Jazz' over time.

i just need two variables: the number of posts from a specific tags and the corresponding date.

Ive searched but i could not find any plugin for that. How should i go about it? Thank you :)

4
  • When you say "searched", have you searched here?
    – brasofilo
    Commented Mar 13, 2013 at 20:11
  • yessir. nothing found :/
    – waqas
    Commented Mar 13, 2013 at 21:28
  • No prob, it's just nice to state that in Question itself, so we know about your research efforts. Anyway, there's an interesting Answer down here, make sure you test the solution and provide feedback to the answerer. Welcome, btw!
    – brasofilo
    Commented Mar 13, 2013 at 21:35
  • 2
    ive been silently reading SE for years(?) now (thanks to google) and this is the first time ive asked anything. i know i shudnt ask unless ive searched as thoroughly as i am capable of. will definitely reply to @kovshenin after i test it out at work tomorrow. and thanks :)
    – waqas
    Commented Mar 13, 2013 at 22:02

2 Answers 2

1

You can do that with a custom SQL query, something along the lines of:

global $wpdb;
$results = $wpdb->get_results( "SELECT DATE(post_date) AS d, COUNT(*) AS c FROM $wpdb->posts WHERE post_status = 'publish' GROUP BY d" );

You'll get an array of objects where d is the date and c is the number of posts published on that date. You should also put LIMIT constraints if you plan to query large datasets.

Hope this helps.

0

Just asking the same question myself, and i found this guy: digwp.com/2011/04/graphing-blog-comments-over-time

he's doing something slightly more complicated (graphing the number of comments per post per day), but starting with a very similar query to kovshenin and drawing a neat little css graph. It's not a complete module, but he's made all his code available.

1
  • Can you provide a bit more of a technical answer. Link only answers aren't usually considered quality answers. If the link becomes inactive, the answer becomes benign. Commented Apr 8, 2013 at 6:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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