How Old Am I WordPress plugin

How Old Am I is a plugin for WordPress, which calculates and displays your age in several formats, giving you up-to-date detailed age information which can be added on your posts and pages, without having to constantly update them.

You can download it either from the WordPress plugins directory or from GitHub.

For any feedback or issues, feel free to post a comment or contact me directly.

Screenshots


Example of usage: Default settings


Example of usage: Custom format with age in numbers


Example of usage: Custom format with age in full


The plugin’s settings

Main photo by wagaboy

there are 5 comments:

  • Hi,
    I love your simple approach. I have a small question, is it easy to add a parameter like “onpost” to give the age on the day of posting?
    I would like to add this to every post (or maybe put this in the theme, or other position?)
    Regards,
    Martijn

    Reply to comment ↓
    • Hello Martijn,

      From what I can understand, you want to specify a parameter in the plugin, so it will always show a specific age, regardless of the current date?

      For example, let’s say that I specify 1/1/1980 as my birthday. If today is 1/1/2030, and I use the plugin as it is now, it will display something like “50 years old”.

      But, if I use it specifying a date when I call the plugin (e.g. [how-old-am-i on="01-01-2020"]), it will override today’s date, and it will display “40 years old”.

      I’m not sure if it can be done without specifying a specific date when the plugin is called (and instead grabbing the date from the post).

      Let me know if the above is similar to what you are after (if not, please explain using a few use cases), and I’ll try to include something like that in the plugin.

      Reply to comment ↓
  • Hi Stathis,
    I added your script a little bit (and dirty ;-)) I wanted to see the age my son is at the day of posting.
    I modified it like this, maybe you can clean it up and make it better:

    function displayAge($atts)
    {
    $options = $this->getAdminOptions();

    $returnValue = ”;
    $onpost = get_the_date();

    extract( shortcode_atts( array(
    ‘onpost’ => ‘no onpost’
    ), $atts));

    if($options['php']===’latest’)
    {
    $birthDate = new DateTime();
    $birthDate->setDate($options['birthYear'], $options['birthMonth'], $options['birthDay']);
    $now = new DateTime(“now”);
    if ($onpost!=’no onpost’)
    {
    $now->setDate(get_the_date(‘Y’),get_the_date(‘m’),get_the_date(‘d’));
    }
    ….

    Reply to comment ↓
    • however, i figured that it would be better to edit the theme

      Reply to comment ↓
      • Thanks for the ideas. :)

        I added a couple of shortcode attributes, and uploaded a new version of the plugin.

        Reply to comment ↓

Leave a Reply

Thanks for leaving a comment. Please do not post spammy comments just to get some backlinks; all links are "nofollow" and the spammy comments will be deleted.