Support » Plugins » Post Count Today?

  • Hey guys,

    I was wondering if anybody knew of a way to retrieve the days post count?

    So only a total number of posts made that current day.

    Any kind of plugin or example I could look at before trying to build this plugin?

    Any help or suggestions are appreciated.

    Thanks,
    Mario

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Ethics

    (@ethics)

    Hey,

    Thank you for the quick reply.

    Unfortunately it seems that the code provides a count for the number of posts in the last 24 hours. This causes posts to be shown from the previous day until they have been around for 24 hours.

    I’m trying to wrap my head around the formula and how we can make it only count the current days posts.

    Here is the code if anybody wants a look at it…

    [code]
    $today = date("Y-m-d H:i:s"); //Today's date
    $daysago = date("Y-m-d H:i:s",strtotime(date('Y-m-j H:i:s')) - (1 * 24 * 60 * 60)); //Today - 1 day

    $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish' AND post_date BETWEEN '$daysago' AND '$today'");

    if ($numposts >0) {
    echo $numposts.' Wallpapers Added';
    } else {
    echo "0 Wallpapers Added";
    }
    [/code]

    You have a beautiful website btw.

    Oh and if you can update the code on the website to have a closing curly brace at the end that would save alot of headaches 🙂

    Thanks,
    Mario

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Post Count Today?’ is closed to new replies.