tags:

views:

17

answers:

1

I realize this question may be theme specific, but I'm not sure if there's a plugin. I'd like to hide the date for older WordPress posts (anything older than this year). Here's code I found online regarding this subject -- but I'm not sure it could work for my particular theme (it's supposed to replace the date code).

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  }?>

Here's what I have in my functions.php (I'm running one of the StudioPress themes).

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;
}  
A: 

Put the original add_filter into a comment and add this code to your 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]';
}  

Haven’t tested this yet …

toscho