尝试显示已发布日期和更新日期(如果它与发布日期不同),我在wordpress模板中尝试了此代码:
<p class="card-text">Published <?php the_date();?>.
<?php
if ( the_date( 'U' ) !== the_modified_date( 'U' ) ) {
echo "Updated " . the_modified_date('F j, Y');
}
?>
然而,我做网获得任何输出。可能很简单,但我只能输出很长的数字。
答案 0 :(得分:1)
您应该使用get_the_date
和get_the_modified_date
,因为它们会返回值而不会将其打印出来。
if ( get_the_date( 'U' ) !== get_the_modified_date( 'U' ) ) {
echo "Updated " . get_the_modified_date('F j, Y');
}