those boots are so damn cheeky

WordPress Plugin: Display number of days since first post

This plugin shows the number of days between now and the first day you published an entry.

It’s free to use for anyone, have fun.

Instructions:

  • Copy text below into a blank text file named days_old.php (using Notepad or SimpleText)
  • Upload that text file to your plugins directory (usually wp-content/plugins)
  • Activate it under Plugins in your admin
  • Call it from a template by inserting the line:
    <?php days_since_birth(); ?>

    This will give you a number which is the number of days between now and when your first post was published.

I do not provide support of any kind for this script.

24 comments

Ravi U

Very nice for those of us with no knowledge of PHP/WordPress ;-) . Just one thing though…might want to take off those couple spaces at the end of the code as it can lead to problems when activating the plugin (applies to any plugin, actually). Other than that, great!

Martin

Hmm when i upload days_old.php to my plugin folder and activate it all i get is a white page, nothing works and when i delete the file from the server everything works again, do you know what the problem is?

cheekyboots

Not really. Check that you uploaded it as ASCII and not binary, that there are no spaces or linebreaks where there shouldn’t be.

Martin

Thank you but it doesnt work. The page turns blank/white when i upload it and clicking on Site admin or whatever i do its blank. I have no spaces or linebreaks in the code and i uploaded it in ASCII. I’m gonna look deeper in this.

vally

It makes it at my site too…

Becca

Great plugin :)

As my blog was nearly a year old, I thought I’d edit the plugin a bit to display years as well. For blogs under a year old, it displays “days old”, but for blogs that are over a year old, it displays the number of years as well, with an ‘s’ if there is more than one year. If it is exactly on the year (365 days old = 1 year old, 730 days old = 2 years old), it doesn’t display days. The link right below is the link to the edited plugin.

http://www.breakfastclubber.com/files/days_and_years_old.txt

Serge Norguard

Fatal error: Call to undefined function: days_old() in /../../footer.php on line 18

line 18 =

Scott Grayban

Linux users will need to change the line

$now = gmdate(”Y-m-d H:i:s”,time());

to

$now = gmdate(‘Y-m-d H:i:s’,time());

For this to work.

Scott Grayban

This works for us linux users instead.

[code]
$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 days old.

Scott Grayban

Uggg it didn’t work :(

Just contact me from my blog and I’ll email you back with what works for me.

cheekyboots

Hmm. I’m using Linux, and the code I presented works on my server. Could be your specific variety of Linux, or something else.

Marcos

There was a problem with quotes. WordPress makes more fancy the code, changing characters. It would be a better idea offering a .php or .txt file for downloading.

These are the lines that worked for me:

$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

Jeroen

I’ve got the same problem. As soon as i activate the plugin, everything turns blank! Is this plugin WP2-compatible?

cheekyboots

Yes – I am running 2.0 and I use the plugin.

Babz

I had the same problem with installing and getting an error message once the plugin was uploaded.

I think the problem is coming from copy and pasting it into the text form.

In my situation I was seeing blocks instead of ” When I corrected that it worked. So if you are copy then pasting the code check it before installing.

Great Plugin by the way! Love it ;)

Nikolay

The problem is the curly quotes in the code:

$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

It should contain only straight, ASCII single and double quotes, no inverted commas:

$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

Steinar

Thanks, Emma, nice plugin.

I put the file here if anyone’s interested http://foynland.org/files/days_old.rar

Annica

This plugin doesn’t work with the new version of wordpress. Care to update?

cheekyboots

I’m using WP 2.1-alpha1 and it works fine. If I ever upgrade and it breaks, I’ll fix it, otherwise not likely.

theddy

Hi

Version 1.0 of your plugin seems not to be compatible with WP 2.1 – the day count is wrong.

Thanks.

Jen

This plugin doesn’t work with 2.1, I was using it when I installed the new version (followed the instructions and deactivated it of course), and when I activated it again it said that my blog had been up for 2611 days (in reality it has only been up for 22 days)…

cheekyboots

It works for me, must be something else going on. However, it is a very very simple script and I’m sure you can either fix it or make your own. I’m closing the comments on this post. Use the script if you want or don’t if you want. I’m not interested in supporting it.