Adding an age as a custom meta value (2 posts)

  1. lewiscornwell
    Posted 2 years ago #


    I am building a search script that will filter results based on ages. (Posts are people on my site) The age is entered as a date of birth in a custom field. I am confident I can write a function to convert this date of birth to an age, then add it again as another custom field.

    My only worry is, what happens each year when they get older? I am not too sure what to do. I could have a script that runs each day...but this feels like a cheat.

    Any ideas?

    Many thanks

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    Why store the age when you already have a date of birth? The search script should be able to calculate current age on-the fly using the current date.

Topic Closed

This topic has been closed to new replies.

About this Topic