admin管理员组文章数量:1122832
The actual question is how to create a counter for new posts for a certain time (per hour or per day) on a Wordpress blog. So that you can place it in the site menu. Thank you very much in advance :)
I found this code, as I understand it, it needs to be placed in the functions.php file, but I don’t understand how to add displays of the counter itself to the menu.
$posts= get_posts(array(
'numberposts' => -1,
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
'date_query' => array(
'column' => 'post_date',
'after' => '-7 days' // -7 Means last 7 days
)
));
When I add this code to the menu it always shows 0:
<h3>Post Count: <?php echo count($posts); ?></h3>
Tell me how to fix this?
本文标签: customizationDisplay Published Posts Count for Time Period
版权声明:本文标题:customization - Display Published Posts Count for Time Period 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736308317a1933618.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论