Home › Forums › General Issues › Entering and Displaying Time Duration › Reply To: Entering and Displaying Time Duration
Hi @awilder
The best solution is to create a custom field type for you specific needs.
You can read how this is possible here:
http://www.advancedcustomfields.com/resources/tutorials/creating-a-new-field-type/
If a faster approach is needed, I would create 2 select fields; one for hour and the other for minutes.
The label for each value would look pretty like “2 hours”, but the value it saves would be “2”. This way, you can construct the schema.org recipe markup like so:
<?php
$hours = get_field('hours');
$minutes = get_field('minutes');
$markup = 'PT';
if( $hours )
{
$markup .= $hours . 'H'
}
if( $minutes )
{
$markup .= $minutes . 'M'
}
echo $markup;
?>
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.