我意识到这个问题可能是主题特定的,但我不确定是否有插件。我想隐藏旧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;
}
答案 0 :(得分:1)
将原始add_filter
放入评论中,并将此代码添加到您的functions.php:
add_filter('genesis_post_info', 'post_info_filter2');
function post_info_filter2($post_info)
{
global $post;
// A leap year has 31622400 seconds, but we’ll ignore that.
$datestring = ( time() - strtotime($post->post_date) > 31536000 )
? '' : '[post_date] ';
return $datestring . 'by [post_author_posts_link] at [post_time] [post_comments] [post_edit]';
}
尚未对此进行测试......