查看下面的代码。函数返回以todays日期发布的许多帖子。您只需稍微修改导航,即可将此数字计数器添加到菜单栏。
echo "<h1>Today is: " . date("Y-m-d") . "</h1>";
function published_today() {
$counter = 0;
$posts = get_posts(array(\'numberposts\'=>-1));
foreach ($posts as $post){
if (get_the_time(\'Y-m-d\', $post->ID) === date("Y-m-d")) {
$counter++;
}
}
return "Posts published today: " . $counter;
}
echo published_today();