WordPress.org

Ready to get started?Download WordPress

Forums

Display how many posts were published within last 24 hours (2 posts)

  1. John Robertson
    Member
    Posted 3 years ago #

    As the title says, I would like to display how many posts were published within the last 24 hours. Can that be done?

  2. svil4ok
    Member
    Posted 3 years ago #

    If i understand you, you want to display number of the posts published within a day ? Here is example:

    <?php
    $last_24 = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status = 'publish' AND TIMEDIFF(NOW(), post_date) < '24'");
    echo $last_24;
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.