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 need to show my users cumulative posts and members registered count by date. It has to be displayed in an array format like this

for posts

array(array(2011,08,02), 500)
array(array(2011,08,03), 520)
array(array(2011,08,04), 540)
array(array(2011,08,05), 560)
array(array(2011,08,06), 580)

the same case for members

iam using wordpress.com stats to for statistics, i cant figure out how to do this, could anyone help me...

share|improve this question
    
Why in that format? Are you importing this data into another system? When you say users cumulative posts do you mean you want data per user or all the users combined? Do you want to exclude admin posts? –  Brady Aug 4 '11 at 15:39
    
@brady i need cumulative posts per date, regardless of the user, like today- 200, yesterday-180 ..... in an array format so that i can form a graph based on that. –  Ezhil Aug 5 '11 at 5:04
    
do you need it as a one off script or as a plugin? –  Brady Aug 5 '11 at 8:07
add comment

1 Answer 1

up vote 0 down vote accepted

Here is a very crude script I've knocked up to get what you are after:

<?php
require('wp-blog-header.php');

$posts = get_posts('numberposts=-1&order=ASC');

$posts_times = array();

foreach ($posts as $post) {
    $post_time = strtotime($post->post_date);
    $offset = $post_time % (60*60*24);
    $post_time -= $offset;
    $posts_times[$post_time]++;
}

$keys = array_keys($posts_times);

$running_count = 0;

$end_data = array();

for($i = $keys[0]; $i <= $keys[(count($keys)-1)]; $i += (60*60*24)) {
    $running_count += $posts_times[$i];
    $end_data[] = array(
        array(date("Y", $i), date("m", $i), date("d", $i)),
        $running_count
    );
}
echo "<pre>";
print_r($end_data);
?>
share|improve this answer
add comment

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.