I thought I was becoming a guru of wordpress, but I was stumped today.
I would like an if statement that checks if the post has been published for more than a week. If it hasn't, I'll display a "New" sticker. If it has, then the sticker goes away.
Seems simple enough, but after an hour of searching and attempting, I figured I would just ask.
<?php
$mylimit=7 * 86400; //days * seconds per day
//$post_age = date('U') - get_post_time('U');
$post_age = date('U') - mysql2date('U', $post->post_date_gmt);
if ($post_age < $mylimit) {
echo 'this post is within my date limit ';
}
?>
I bow to the master bow
Question though: Why multiply by the seconds per day?
As I typed that, I realized why. The MySQL speaks in seconds, so how many seconds in a week? Well you'd multiply the number of seconds in a day times the number of days. So if the post is a week old, it echos.
Never mind, question answered. Still bowing. Any advice for a kid trying to break out from the pack around here?
Any advice for a kid trying to break out from the pack around here?
Buy low and sell high!!