• Hi! Do you know how to display total number of posts published today ?
    whit this code not work:

    <?php
    $post_date = mysql2date(“Ymd”, $post->post_date_gmt);
    $numpost = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = ‘publish’ And post_date==post_date_gmt”);

    echo $numpost;
    ?>

    Thx

Viewing 4 replies - 1 through 4 (of 4 total)
  • <?php
    $today = getdate();
    $todayposts=get_posts('year=' .$today["year"] .'&monthnum=' .$today["mon"] .'&day=' .$today["mday"] );
    echo 'Count of posts dated today is '. count($todayposts);
    ?>
    Thread Starter alin1987

    (@alin1987)

    hi. i posted 5 post today and work, but I have 6 posts published today and the code display 5 . At 10 posts published today, the code show 5. any ideas?

    Ah, that’s probably the number of posts from your Reading Settings so
    change

    $todayposts=get_posts('year=' .$today["year"] .'&monthnum=' .$today["mon"] .'&day=' .$today["mday"] );

    to

    $todayposts=get_posts('numberposts=-1&year=' .$today["year"] .'&monthnum=' .$today["mon"] .'&day=' .$today["mday"] );

    Thread Starter alin1987

    (@alin1987)

    ok. Thx. Is ok now

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘total number of posts published today’ is closed to new replies.