Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I recently migrated a blog from sub.domain.com to blogs.domain.com/sub/. Because I'm using Facebook comments, all the posts published before April 25 need to reference sub.domain.com/blog-entry-title as the fb:comments href.

I know how to display certain posts for my date range with this code:

<?php
      function filter_where($where = '') {
      //posts for Jan 1 to April 26, 2012
    $where .= " AND post_date >= '2012-03-01' AND post_date <= '2012-03-15'";
    return $where;
      }
add_filter('posts_where', 'filter_where');
query_posts($query_string);
?>

But can I manipulate this code to use at the template level to say: "If post published before April 25, display xyz comments; else display abc comments."

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Sure, you can do something like this in your template code:

<?php
    $migrate_date = mktime(0,0,0,1,1,2012);
    if ( get_the_date('U') > date('U', $migrate_date) ) {
        echo "<p>New</p>\n";
    } else {
        echo "<p>Old</p>\n";
    }
?>
share|improve this answer
    
Hmm, that sesms right but not quite working. –  lauren Apr 26 '12 at 20:35
    
I added the code above to my template's single.php and tested on a few pages. It works. –  cpilko Apr 26 '12 at 21:32
    
Aha! I see what I did wrong; just needed to change the date. Thank you. –  lauren Apr 26 '12 at 23:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.