WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

      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');

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
up vote 0 down vote accepted

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

    $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


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.