days since first post
-
hi, i just want to add a count that counts the days since post, but this thing wont work:
<?php
/*
Plugin Name: Days Since Birth
Plugin URI: https://www.cheekyboots.com/?page_id=15
Description: Outputs the total number of days since first blog post.
Version: 1.0
Author: Emma M.
Author URI: https://www.cheekyboots.com
*/ </p>
<p>function days_since_birth() {
global $wpdb;
$now = gmdate(”Y-m-d H:i:s”,time());
$first_post = $wpdb->get_results(”SELECT post_date_gmt FROM $wpdb->posts WHERE post_status = ‘publish’ AND post_date < '$now' ORDER BY post_date ASC Limit 1");
if ($first_post) {
foreach ($first_post as $post) { </p>
<p> $first_day=strtotime($post->post_date_gmt);
$now=strtotime($now);</p>
<p> //Then you subtract the lower date from the higher.
$between = $now - $first_day;</p>
<p> //Finally your divide the result by the number of seconds on a day.
$days_old = $between / (24*3600); </p>
<p> }
} else {
$days_old=0;
}
echo round($days_old);
}
?>
it’s from: https://www.cheekyboots.com/?page_id=15
- The topic ‘days since first post’ is closed to new replies.