show number of posts posted today

You can use WP_Query like this:

// we get the date for today
$today = getdate();
//we set the variables, i am ignoring sticky posts so they dont get counted
$args = array(
    'ignore_sticky_posts' => 1,
    'posts_per_page' => -1, //all posts 
    'date_query' => array(
        array(
            'year'  => $today["year"],
            'month' => $today["mon"],
            'day'   => $today["mday"],
        ),
    ),
);

//we create the query
$today_posts = new WP_Query( $args );
//the result already has a property with the number of posts returned
$count = $today_posts->post_count;
//show it
echo $count;

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)