【发布时间】:2010-09-14 03:52:46
【问题描述】:
我意识到这个问题可能是特定于主题的,但我不确定是否有插件。我想隐藏旧 WordPress 帖子的日期(任何比今年更早的帖子)。这是我在网上找到的关于这个主题的代码——但我不确定它是否适用于我的特定主题(它应该替换日期代码)。
01 <?php
02 $today = date('r');
03 $articledate = get_the_time('r');
04 $difference = round((strtotime($today) - strtotime($articledate))/(24*60*60),0);
05 if ($difference >= 30)
06 {
07 ?>
08 <!-- Aged Gem -->
09 <?php
10 } else {?>
11 <!-- Fresh Gem --><strong><?php the_time('F jS, Y') ?></strong>
12 <?php
13 }?>
这是我的 functions.php 中的内容(我正在运行 StudioPress 主题之一)。
add_filter('genesis_post_info', 'post_info_filter');
function post_info_filter($post_info) {
$post_info = '[post_date] by [post_author_posts_link] at [post_time] [post_comments] [post_edit]';
return $post_info;
}
【问题讨论】: