如果发布日期or 修改日期早于1年,如果是,请在帖子页面上显示消息。
我已将代码添加到content-single.php
文件,但在检查发布和更新时间方面没有期望的结果。
Example:
if (strtotime($post->post_date) < strtotime(\'-1 year\')){
echo \'Old Post\';
} else {
echo \'Not Old Post\';
}
有什么想法吗,因为我现在还不知道。。如果发布日期or 修改日期早于1年,如果是,请在帖子页面上显示消息。
我已将代码添加到content-single.php
文件,但在检查发布和更新时间方面没有期望的结果。
Example:
if (strtotime($post->post_date) < strtotime(\'-1 year\')){
echo \'Old Post\';
} else {
echo \'Not Old Post\';
}
有什么想法吗,因为我现在还不知道。。现在你只是在检查发布日期。您还需要检查“post\\u modified”。您可以在此处找到完整的post对象:https://developer.wordpress.org/reference/functions/get_post/#user-contributed-notes
您可以将支票修改为如下所示:
if (strtotime($post->post_date) < strtotime(\'-1 year\') && strtorime($post->post_modified) < strtotime(\'-1 year\')){
echo \'Old Post\';
} else {
echo \'Not Old Post\';
}
这两种情况都应该得到证实。我搜索了整个网络和stackexchange,寻找原因和解决方案,但没有找到任何答案。关于自己的插件以及如何在激活时创建表的代码,有很多问题(和答案)。但这不适用于这里,因为我对wordpress插件库中的知名插件和维护插件有这个问题。So, the situation:一个拥有约20个docker堆栈的kvm来宾。每个堆栈由一个nginx、一个php:8-fpm和一个mariadb容器组成。nginx容器中有一个web目录作为共享卷,其中包含wordpress安装。(所以我没有使用wordpress d