Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试计算我的 wordpress 网站上时间戳大于或等于今天的帖子数量。
我已将当前时间和发布时间戳放入两个变量中,并猜测它会开始:
if ($timestamp >= $curent_time) {
还包括count也许the_post()
count
the_post()
但我被困住了。我无法弄清楚如何将它组合在一起。有任何想法吗?
您应该对您的帖子进行某种循环,然后增加条件内的计数器,例如:
$curent_time = date('d-m-Y'); //or whatever format date $cont = 0; //for each post foreach($posts as $post){ $timestamp = $post['timestamp'] // or whatever if ($timestamp >= $curent_time) { $cont++; } } echo $cont;