如果WordPress评论日期低于2014年4月,如何显示p标签

How to Display a p tag if WordPress comment date below April 2014?

本文关键字:何显示 显示 标签 日期 评论 WordPress 4月 2014年 如果      更新时间:2023-09-26

我需要在评论日期低于2014年4月时显示HTML。这是我的wordpress日期代码

<time datetime="2014-05-26T12:19:33+00:00">May 26, 2014 at 12:19 pm</time>

我想显示以下HTML

<p class="comment-rating"> <img src="#"><br>Rating: <strong>5 / 5</strong></p>

这可能吗?

通常情况下,您应该显示到目前为止所做的尝试。

有一种方法:

$(function () {
    var checkDate = new Date("2014-05-01");
    $.each($("time"), function () {
        var $timeItem = $(this);
        var currentDate = new Date($timeItem.attr("datetime"));
        if (currentDate < checkDate) {
            $timeItem.after('<p class="comment-rating"> <img src="#"><br>Rating: <strong>5 / 5</strong></p>');
        }
    });
});

演示:http://jsfiddle.net/36bg4/2/