days since first post (1 post)

  1. to_ul
    Posted 7 years ago #

    hi, i just want to add a count that counts the days since post, but this thing wont work:

    Plugin Name: Days Since Birth
    Plugin URI: http://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: http://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);
    <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 {
    echo round($days_old);

    it's from: http://www.cheekyboots.com/?page_id=15

Topic Closed

This topic has been closed to new replies.

About this Topic