Yay! Good luck and glad it worked.
Also, I checked out your site (Googled “websydaisy”). Nice work.
This worked for me on my test: http://devwrangler.com/dob-test/
<?php
//date in mm/dd/yyyy format; or it can be in other formats as well
$birthDate = get_field('date_of_birth');
//explode the date to get month, day and year
$birthDate = explode("/", $birthDate);
//get age from date or birthdate
$age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) > date("md")
? ((date("Y") - $birthDate[2]))
: (date("Y") - $birthDate[2]));
echo "Age:" . $age;
?>
<?php
$date = get_field('date_of_birth');
$birthday = new DateTime($date);
$interval = $birthday->diff(new DateTime);
echo $interval->y.' years old';
?>
What is the date format being used for this field? Some PHP should be able to handle this based on the current date. Do you have a QA site you can share with me?
Here’s a version to show both the label and value for a sub field in a repeater.
<?php if( have_rows(‘distribution_list’) ): ?>
<div id=”distributors”>
<?php while( have_rows(‘distribution_list’) ): the_row();
$select = get_sub_field_object(‘country’);
$value = get_sub_field(‘country’);
$label = $select[‘choices’][ $value ];
?>
<li class=”<?php echo $value; ?>”><?php echo $label; ?>
<?php endwhile; ?>
</div>
<?php endif; ?>
What worked for me was adding <?php acf_form_head(); ?> BEFORE <?php get_header(); ?> at the top of the page template.
ckirk, how did you get the title to set from another field?
I need that to work, but I keep getting “no-title” when the post is created.
Where did you get “field_1234”? Is it the field key?
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.