I would like to display count for custom post types (or posts) which was published that day (last 24 hours or TODAY).
I use this snippet to get count of all posts from “posts” or from “custom post types”
<?php
$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE (post_status = 'publish' AND post_type = 'post')");
if (0 < $numposts) $numposts = number_format($numposts);
?>
in templates:
<?php echo $numposts ?>
but I don’t know how to display count only for last 24 hours or TODAY (it means from midnight to midnight)
You can write your own function (add it to
functions.php
file:And then use it in template: