Support Forums

Support Forums Forums Search & Filter Pro Filter by date ranges (

This topic is: not resolved
Viewing 2 posts - 1 through 2 (of 2 total)
  • paulka

    I have a list of dogs up for adoption. I would like to filter them by age groups progmatically.


    User is given the choices:
    Young Adult

    But the search form uses the DOB (stored in an ACF field as MM Y) to filter the results into the 4 gorups

    I already display the text age using this IF

    $now = new DateTime();
    $dob = new DateTime($data);
    $difference = $now->diff($dob);
    $age = $difference->m + 12*$difference->y;
    if ($age <= 12) {
    		$agegroup = "Age: Puppy/Kitten";
    } elseif ($age <= 36) {
    		$agegroup = "Age: Young Adult";
    } elseif ($age <= 72) {
    		$agegroup = "Age: Adult";
    } elseif ($age > 72) {
    		$agegroup = "Age: Senior";

    Is there a nice way to do this? I would imagine running this for every search query could be quite resource intensive, so if there was a way to cache it and refresh once a week?

    Previously the age group was a field, but this meant older dogs could still be classified as puppies as they weren’t ever updated.

    Trevor Moderator

    There isn’t a way I can think of to do this with the current plugin, sorry.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.