I want to create a shortcode to display the posts posted on actual day.
I found this code: show number of posts posted today And I'm trying with it, but return 0
function ts_day_f() {
// 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
return $count;
}
add_shortcode('ts_day','ts_day_f');
Any idea?