Hmm, I’m not sure that code will get me to where I need to go although I could be interpreting it incorrectly. Let me give some context. I’m trying to put together a list of posts on the single post page that match a specific custom field value. Then I want to take that list and attach an icon indicating that it’s a new post. I’ll attach the important parts of code I’m using.
<?php
global $wpdb;
$findposts = $wpdb->get_results(
"SELECT *
FROM $wpdb->posts
LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id)
WHERE $wpdb->postmeta.meta_key = 'Serial'
AND $wpdb->postmeta.meta_value = '$serial_value'
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->posts.post_type = 'post'
AND $wpdb->postmeta.post_id != $id
ORDER BY $wpdb->posts.post_date ASC"
);
?>
<ul>
<?php $limit = 6; ?>
<?php foreach ($findposts as $findpost): ?>
<?php $counter_serp++; ?>
<?php $fp_id = $findpost->ID;
$fp_title = $findpost->post_title;
$fp_url = $findpost->guid;
$fp_date = $findpost->post_date;
?>
<?php $mylimit=60 * 86400; $post_age = date('U') - $fp_date;?>
<li class="related">
<?php if ($post_age <= $mylimit) { ?><span class="info_icon new">New</span> <?php } ?>
<a href="<?php echo $fp_url; ?>" title="Permalink to <?php echo $fp_title; ?>"><?php echo $fp_title; ?></a>
</li>
<?php if($counter_serp >= $limit) break; ?>
<?php endforeach; ?>
</ul>
So basically I need to either get the post date by post ID and convert that to seconds so I can compare or convert the post_date string into seconds. Any ideas? Thanks.